﻿// ==UserScript==
// @name ClanInfo
// @author Vov_chiK
// @namespace http://userscripts.org/people/521608
// @description Adding additional information on members of the clan
// @source http://userscripts.org/scripts/show/171246
// @identifier http://userscripts.org/scripts/source/171246.user.js
// @copyright 2013+, Vov_chiK
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @version 0.6.7
// @creator Vov_chiK
// @include http://worldoftanks.ru/uc/clans/*
// @include http://worldoftanks.com/uc/clans/*
// @include http://worldoftanks.kr/uc/clans/*
// @include http://worldoftanks.asia/uc/clans/*
// @include http://worldoftanks.eu/uc/clans/*
// @include http://worldoftanks.ru/community/clans/*
// @include http://worldoftanks.com/community/clans/*
// @include http://worldoftanks.kr/community/clans/*
// @include http://worldoftanks.asia/community/clans/*
// @include http://worldoftanks.eu/community/clans/*
// @match http://worldoftanks.ru/uc/clans/*
// @match http://worldoftanks.com/uc/clans/*
// @match http://worldoftanks.kr/uc/clans/*
// @match http://worldoftanks.asia/uc/clans/*
// @match http://worldoftanks.eu/uc/clans/*
// @match http://worldoftanks.ru/community/clans/*
// @match http://worldoftanks.com/community/clans/*
// @match http://worldoftanks.kr/community/clans/*
// @match http://worldoftanks.asia/community/clans/*
// @match http://worldoftanks.eu/community/clans/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
// @Vov_chiK

var version = '0.6.7';
var name_link = '[ClanInfo] Расширенная статистика по клану на оф. сайте.';
var link = 'http://forum.worldoftanks.ru/index.php?/topic/881743-claninfo-%D1%80%D0%B0%D1%81%D1%88%D0%B8%D1%80%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F-%D1%81%D1%82%D0%B0%D1%82%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B0-%D0%BF%D0%BE-%D0%BA%D0%BB%D0%B0%D0%BD%D1%83-%D0%BD%D0%B0-%D0%BE%D1%84-%D1%81%D0%B0%D0%B9%D1%82%D0%B5/';
var token = 'Intellect_Soft-WoT_Mobile-ClanInfo'+version;
var maxtask = 4;

if(window.location.host.indexOf("worldoftanks") > -1 && window.location.href.indexOf("clans") > -1){
	var lang;
	var localization;	
	var host = window.location.host;
	var clanInfo = (window.location.href.split('/'))[5].split('-');	
	var clanId = clanInfo[0];
	var clanTag = clanInfo[1];
	if(clanInfo.length > 2){
		for(ct = 2; ct < clanInfo.length; ct++){
			clanTag += '-'+clanInfo[ct];
		}
	}
	
	var xdr = {
		reqId : 0,
		req : {},
		prepareUrl : function(url){
			return url;
		},
		xget : function(url, onDone){
			url = this.prepareUrl(url);
			if (window.opera && window.opera.defineMagicVariable){
				this.scriptTransport(url, onDone);
			}else 
			if(GM_xmlhttpRequest){
				this.GMTransport(url, onDone);
			}else if(chrome && chrome.extension){
				this.xhrTransport(url, onDone);
			}else{
				var currentReqId = this.reqId++;
				this.req[currentReqId].handleJSONP = function(response){
					var info = (url.split('/'))[4];
					if(info == 'accounts'){
						var player = JSON.parse(response);
						if(player.status == 'error'){	
							onError(url);
						}else{
							getMembers(response);
						}						
					}else{
						onDone(response);
					}
				};				
				this.JSONPTransport(url, "xdr.req["+currentReqId+"].handleJSONP");
			}
		},
		scriptTransport : function(url, onDone){
			var t = document.createElement("script");
			t.src = url;
			t._callback = function(response){
				var info = (url.split('/'))[4];
				if(info == 'accounts'){
					var player = JSON.parse(response);
					if(player.status == 'error'){	
						onError(url);
					}else{
						getMembers(response);
					}						
				}else{
					onDone(response);
				}
			};
			t.onerror = function(){onError(url);};
			document.body.appendChild(t);
		},
		xhrTransport : function(url, onDone){
			chrome.extension.sendRequest(
				{'action' : 'xget', 'url': url}, 
				function(response){
					var info = (url.split('/'))[4];
					if(info == 'accounts'){
						var player = JSON.parse(response);
						if(player.status == 'error'){	
							onError(url);
						}else{
							getMembers(response);
						}						
					}else{
						onDone(response);
					}
				}
			);
		},
		GMTransport : function(url, onDone, errorMsg){
			setTimeout(function(){
				GM_xmlhttpRequest({
					method : "GET",
					url : url,
					onload : function(x){
						try{
							var o = x.responseText;
							if(onDone){
								var info = (url.split('/'))[4];
								if(info == 'accounts'){
									var player = JSON.parse(o);
									if(player.status == 'error'){	
										onError(url);
									}else{
										getMembers(o);
									}						
								}else{
									onDone(o);
								}
							}
						}catch(e){
							onError(url);
						}
					}
				});
			}, 0);		
		},
		JSONPTransport : function(url, callbackName, errorMsg){
			if (callbackName && typeof callbackName == "string"){
				url += "&callback="+callbackName;
			}
			var t = document.createElement("script");
			t.src = url;
			t.onerror = function(){onError(url);}
			document.body.appendChild(t);
		}	
	}
	
	function addScript(callback){
		var script = document.createElement("script");
		script.async = true;
		script.textContent = callback.toString();
		document.head.appendChild(script);
	}

	function main(){
		lang = getCookie('hllang');
		localization = getLocalization();
		
		var content = document.getElementsByClassName("b-clan-profile")[0];
		if(content === undefined){return;}
		content.setAttribute('style', 'width: 950px;');
		
		var b_wrap = document.getElementsByClassName("b-wrap")[0];
		b_wrap.setAttribute('style', 'width: 698px;');
		
		var divContent = content.getElementsByTagName('div');
		for(var divI = 0; divI < divContent.length; divI++){
			if(divContent[divI].getAttribute('class') == 'b-text-info'){
				divContent[divI+1].setAttribute('style', 'width: 698px; min-height: 180px;');
				break;
			}
		}
		
		{var StyleText = ''+
			'span.clainfoscript{color: #606061; font-size:13px; cursor:pointer;}'+
			'span.hide:hover{border-bottom: 1px dotted #F25322;}'+
			'span.hide{color: #F25322; background: url("/static/3.12.0.3/common/css/block/b-link/img/vertical-arrow.png") no-repeat; background-position: 100% -15px; padding-right: 8px;}'+
			'span.show:hover{border-bottom: 1px dotted #F25322;}'+			
			'span.show{color: #F25322; background: url("/static/3.12.0.3/common/css/block/b-link/img/vertical-arrow.png") no-repeat; background-position: 100% 0px; padding-right: 8px;}'+
			'div.script_block{display: none; margin-bottom: 5px; border: 1px dashed #F25322; text-align: center; padding: 10px;}'+
			'span.developer{color: #606061; font-size:13px;}'+
			'a.name{color: #658C4C; font-weight: bold;}'+
			'a.url{color: #2CA8C7; font-weight: bold;}'+
			'span.showclaninfo{padding-left: 40px; color: #BFBFBF; font-size: 14px;}'+
			'span.block{cursor: pointer;}'+
			'span.block:hover{border-bottom: 1px dotted #F25322;}'+
			'div.style_block{margin: 0px; padding: 0px; border-width: 0px;}'+
			'div.style_block_head{text-align: center; border: 0px; width: 916px;}'+
			'#rating_head_block{text-align: right; margin-right: 15px; padding-bottom: 5px;}'+
			'#battles_head_block{text-align: right; margin-right: 15px; padding-bottom: 5px;}'+
			'#provinces_head_block{text-align: right; margin-right: 15px; padding-bottom: 5px;}'+
			'#cf_head_block{text-align: right; margin-right: 15px; padding-bottom: 5px;}'+
			'#vehicle_head_block{text-align: right; margin-right: 15px; padding-bottom: 5px;}'+
			'#newtableclaninfo th{padding-left: 10px; padding-right: 5px;}'+
			'#newtableclaninfo td{padding-left: 5px; padding-right: 5px;}'+
			'.tooltip{color: #000000; outline: none; cursor: help; text-decoration: none; position: relative;}'+
			'.tooltip span{margin-left: -999em; position: absolute;font-size:13px; font-weight: normal;}'+
			'.tooltip:hover span{border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); position: absolute; left: 0px; top: 2em; z-index: 99; margin-left: 0; width: 130px;}'+
			'.tooltip:hover em{display: block; padding: 0.2em 0 0.6em 0;}'+
			'.title-vehicles:hover{color:#FFFFFF;}'+
			'.title-vehicles{padding: 10px; color: #606061;  font-weight: bold; max-width: 920px;}'+
			'div.member_tank_div{float: left;}'+
			'.classic{padding: 5px 5px; color: #979899; background: url("/static/3.12.0.4/common/css/block/b-tooltip/img/tooltip_bg.jpg") repeat scroll 0 0 transparent; border: 1px solid #454648; font-size:13px; font-weight: normal;}'+		
			'img.img_tank{margin-right: -45px;}'+
			'div.vehicles_img{max-width: 940px;}'+
			'.vehicles_open div.vehicles_img{display:none;}'+
			'div#hide{background: url("/static/3.12.0.3/common/css/block/b-link/img/vertical-arrow.png") no-repeat; background-position: 100% -15px;  padding-bottom: 15px;}'+
			'div#show{background: url("/static/3.12.0.3/common/css/block/b-link/img/vertical-arrow.png") no-repeat; background-position: 100% 30px; padding-right: 8px; padding-bottom: 15px;}'+
			'.statall td.count{color: #E0E0E0; font-size: 20px; padding-left: 38px; padding-bottom: 20px; padding-top: 10px;}'+
			'.statall td.img1{background:url(/static/3.12.0.3/common/css/scss/content/user/img/speedometr-param.png) no-repeat;}'+
			'.statall td.img2{background:url(/static/3.12.0.3/common/css/scss/content/user/img/speedometr-param.png) no-repeat; background-position:0 -50px;}'+
			'.statall td.img3{background:url(/static/3.12.0.3/common/css/scss/content/user/img/speedometr-param.png) no-repeat; background-position:0 -100px;}'+
			'.statall{width: 100%; margin-left: 20px;}'+
			'.statall td{font-size: 18px; padding:5px; font-family: "WarHeliosCondCBold", "Arial Narrow", arial, sans-serif;}'+	
			'#vehicles_hide:hover{color: #FFFFFF;}'+
			'#vehicles_show:hover{color: #FFFFFF;}'+	
			'.vehiclesclan div.rote{padding: 10px; color: #606061;  font-weight: bold; background: url("/static/3.12.0.3/common/css/block/table/img/th-bg.png") repeat-x scroll 0 100% #090A0B;}'+	
			'.tooltip2{color: #000000; outline: none; cursor: pointer; text-decoration: none; position: relative;}'+
			'.tooltip2 span{margin-left: -999em; position: absolute; font-size:13px; font-weight: normal;}'+
			'.tooltip2:hover span{border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); position: absolute; left: -80px; top: -40px; z-index: 99; margin-left: 0; width: 130px;}'+
			'.tooltip2:hover em{display: block; padding: 0.2em 0 0.6em 0;}'+	
			'div.count{top: -15px; position: relative; left: 50px; width: 15px;}'+				
			'td.name_tank_block{padding-left: 10px;white-space: nowrap;border-top: 1px solid #2E3139;padding-top: 10px;width: 130px;}'+
			'div.count_tank{top: -15px; left: 67px; position: relative; bottom: 0px;}'+
			'td.img_tank_block{padding-left: 15px; border-top: 1px solid #2E3139;}'+
			'.vehicleall{width: 100%;}'+
			'.vehicleall td{font-size: 18px; font-family: "WarHeliosCondCBold", "Arial Narrow", arial, sans-serif;}'+	
			''+
		'';}
		var StyleAdd = document.createElement("style");
		StyleAdd.textContent = StyleText.toString();
		document.head.appendChild(StyleAdd);
		
		var AreaButton = document.getElementsByClassName("b-members")[0];
		AreaButton.innerHTML += ''+
			'<div style="text-align: right; padding-top: 5px; padding-bottom: 5px;">'+
				'<span class="clainfoscript hide" onclick="onViewScript();">'+
					localization[lang]['clainfoscript']+' ClanInfo '+version+
				'</span>'+
			'</div>'+
			'<div class="script_block">'+
				'<span class="developer" align="center">'+
					localization[lang]['developer']+
					'<a class="name" href="http://worldoftanks.ru/community/accounts/635939-Vov_chiK/">Vov_chiK</a>'+
					localization[lang]['alliance']+
					'<a class="url" href="http://worldoftanks.ru/community/clans/#wot&ct_search=Walkure">Walkure</a>'+
					'<br /><br />'+
					localization[lang]['topic']+' '+
					'<a id="redirect_link" target="_blank" href="'+link+'">'+
						name_link+
					'</a>'+
				'</span>'+
			'</div>'+
			'<div style="text-align: right;">'+ 
				'<span class="showclaninfo">'+ 
					'<b>'+localization[lang]['information']+'</b>'+ 
					'<div style="float: right; padding: 3px;">'+
						'<div id="checkrunclaninfo" class="b-checkbox" style="cursor:pointer;" onclick="HideShowBlock();">'+
							'<span class="js-checkbox-content"></span>'+
						'</div>'+
					'</div>'+
				'</span>'+ 
			'</div>'+
		'';	
		
		var checkrunclaninfo = document.getElementById("checkrunclaninfo");
		if(checkrunclaninfo.addEventListener){
			checkrunclaninfo.addEventListener('click', runCollectionInfo, false);
		}else{
			checkrunclaninfo.attachEvent('onclick', runCollectionInfo);
		}
		
		addMenuLink();
		addProvincesClan();
		addBattlesClan();
		
		xdr.xget('https://userscripts.org/scripts/source/171246.meta.js', checkVersion);
		
		var b_portalmenu = document.getElementsByClassName("b-portalmenu")[0];
		b_portalmenu.innerHTML += ''+
			'<div class="members-tank" style="display: none;">'+
				'<div style="z-index: 9999; margin-left: -300px; left: 50%; position: fixed; margin-top: -130px; top: 50%;" tabindex="-1" class="ui-dialog ui-draggable no-jquery-buttons" id="us-settings-block">'+
					'<div tabindex="-1" class="ui-dialog-titlebar ui-widget-header ui-corner-all" style="cursor: default;">'+
						'<span class="ui-dialog-title members-tank-title">members-tank-title</span>'+
						'<a tabindex="-1" class="ui-dialog-titlebar-close ui-corner-all us-close-settings members-tank-close" style="cursor: pointer;">'+
							'<span class="ui-icon ui-icon-closethick">close</span>'+
						'</a>'+
					'</div>'+
					'<div style="background: none repeat scroll 0% 0% rgb(31, 31, 31); width: 600px;" class="ui-dialog-content ui-widget-content">'+
						'<div class="js-dialog-content b-dialog-content">'+
							'<div style="background: rgb(31, 31, 31);  min-height: 100px;" class="h-popup-content members-tank-content">members-tank-content</div>'+
						'</div>'+
					'</div>'+
				'</div>'+
				'<div id="us-settings-overlay" class="ui-widget-overlay" style="min-height: 2000px; z-index: 9998;"></div>'+
			'</div>'+
		'';	
		var members_tank_close = document.getElementsByClassName("members-tank-close")[0];
		if(members_tank_close.addEventListener){
			members_tank_close.addEventListener('click', function(){document.getElementsByClassName("members-tank")[0].style.display = 'none';}, false);
		}else{
			members_tank_close.attachEvent('onclick', function(){document.getElementsByClassName("members-tank")[0].style.display = 'none';});
		}
	}
	
	function checkVersion(response){
		var regexp = /@version[^0-9\.]+([0-9a-z\.]+)/gi,
		lastVersion = regexp.exec(response); 
		if(version != lastVersion[1]){
			wg.message_box(
				localization[lang]['box'], 
				localization[lang]['newversion']+" ClanInfo "+
				lastVersion[1]+".<br />"+
				localization[lang]['newupdate']+".", 
				{confirm:{text: "OK", click: function(){}}}
			);			
		}
	}	
	
	function addBattlesClan(){
		var battlesClan = getJson('battles');
		
		if(battlesClan.result == "success"){
			var battles_block_class = 'block';
			var battles_block_height = '0px';
			var block_battles_head = getCookie('battles_head');
			if(null == block_battles_head){
				battles_block_class += ' hide';
				battles_block_height = '0px';
			}else{
				battles_block_class += ' '+block_battles_head;
				if(block_battles_head == 'hide'){battles_block_height = '0px';}else{battles_block_height = 'auto';}
			}		
		
			var battles = document.createElement('div');
			battles.setAttribute('id', 'battles');
			battles.setAttribute('style', 'margin-bottom: 20px;');
			var battlesHTML = ''+
				'<div id="battles_head_block">'+
					'<span id="battles_head" class="'+battles_block_class+'" onclick="onViewBlock(this);">'+
						localization[lang]['battles_head_block']+
					'</span>'+
				'</div>'+
				'<div class="b-user-block b-speedometer-wrpr battles_head style_block" style="height: '+battles_block_height+';">'+
			'';
			if(battlesClan.request_data.total_count > 0){
				battlesHTML += ''+
					'<table class="t-table t-table-sort b-battles-table">'+
						'<thead>'+
							'<tr>'+
								'<th class="js-battles-table type">'+localization[lang]['type']+'</th>'+
								'<th class="js-battles-table time"><span class="js-sort-by-time b-sort-box"><i></i>'+localization[lang]['time']+'</span></th>'+
								'<th class="js-battles-table provinces">'+localization[lang]['provinces']+'</th>'+
								'<th class="js-battles-table arenas">'+localization[lang]['arenas']+'</th>'+
							'</tr>'+
						'</thead>'+
						'<tbody id="js-battles-table-body">'+
							'<tr class="js-template js-hidden">'+
								'<td class="js-hidden js-type b-battle-type"></td>'+
								'<td class="js-hidden js-time b-battle-time"></td>'+
								'<td class="js-hidden js-provinces b-battle-provinces"></td>'+
								'<td class="js-hidden js-arenas b-battle-arenas"></td>'+
							'</tr>'+
				'';
				for(var i = 0; i < battlesClan.request_data.total_count; i++){
					var items = battlesClan.request_data.items[i];
					var name = items.provinces[0].name;
					var id = items.provinces[0].id;
					var started = items.started;
					var iTime = items.time;
					var arenas = items.arenas;
					var type = items.type;
					
					var time = "- - : - -";
					var timestamp = parseInt(iTime);
					if(timestamp != 0){	
						var date = new Date(timestamp*1000);
						var hours = date.getHours().toString();
						if(hours.length == 1){hours = '0'+hours;}
						var minutes = date.getMinutes().toString();
						if(minutes.length == 1){minutes = '0'+minutes;}
						time = hours+':'+minutes;
					}	
					
					var plus = '';
					if(type != 'landing'){plus = ' +';}
					
					battlesHTML += ''+
						'<tr class="odd">'+
							'<td class="js-type b-battle-type"><div><i class="b-battle-icon b-battle-icon__'+type+'"></i></div></td>'+
							'<td class="js-time b-battle-time"><div><span class="time time__aprox js-tooltip js-tooltip-id_js-battle-chips-time-aprox-tooltip">'+time+plus+'</span></div></td>'+
							'<td class="js-provinces b-battle-provinces"><a data-province-id="'+id+'" href="/clanwars/maps/?province='+id+'" class="js-map-province-link">'+name+'</a></td>'+
							'<td class="js-arenas b-battle-arenas">'+arenas+'</td>'+
						'</tr>'+
					'';
				}
				battlesHTML += ''+	
						'</tbody>'+
					'</table>'+			
				'';
			}else{
				battlesHTML += ''+	
					'<div class="js-no-battles-msg b-message-warning">'+
						localization[lang]['battle_no']+
					'</div>'+	
				'';			
			}
			battlesHTML += ''+	
				'</div>'+			
			'';
			battles.innerHTML = battlesHTML;
			var parentElement = document.getElementById('clans_info_content');
			var theFirstChild = parentElement.firstChild;
			parentElement.insertBefore(battles, theFirstChild);
		}	
	}		
	
	function addProvincesClan(){
		var provincesClan = getJson('provinces');

		if(provincesClan.result == "success"){
			var provinces_block_class = 'block';
			var provinces_block_height = '0px';
			var block_provinces_head = getCookie('provinces_head');
			if(null == block_provinces_head){
				provinces_block_class += ' hide';
				provinces_block_height = '0px';
			}else{
				provinces_block_class += ' '+block_provinces_head;
				if(block_provinces_head == 'hide'){provinces_block_height = '0px';}else{provinces_block_height = 'auto';}
			}		
		
			var provinces = document.createElement('div');
			provinces.setAttribute('id', 'provinces');
			provinces.setAttribute('style', 'margin-bottom: 20px;');
			var provincesHTML = ''+
				'<div id="provinces_head_block">'+
					'<span id="provinces_head" class="'+provinces_block_class+'" onclick="onViewBlock(this);">'+
						localization[lang]['provinces_head_block']+
					'</span>'+
				'</div>'+
				'<div class="b-user-block b-speedometer-wrpr provinces_head style_block" style="height: '+provinces_block_height+';">'+
			'';
			if(provincesClan.request_data.total_count > 0){
				provincesHTML += ''+
					'<table class="t-table t-table-sort b-provinces-table">'+
						'<thead>'+
							'<tr>'+
								'<th class="js-provinces-table type">'+
									'<span class="js-sort-by-type b-sort-box b-sort-box__nowrap"><i></i>'+localization[lang]['type']+'</span>'+
								'</th>'+
								'<th class="js-provinces-table name">'+
									'<span class="js-sort-by-name b-sort-box"><i></i>'+localization[lang]['title_name']+'</span>'+
								'</th>'+
								'<th class="js-provinces-table arena_name">'+
									'<span class="js-sort-by-arena_name b-sort-box"><i></i>'+localization[lang]['arenas']+'</span>'+
								'</th>'+
							   '<th class="js-provinces-table prime_time">'+
									'<span class="js-sort-by-prime_time b-sort-box"><i></i>'+localization[lang]['prime_time']+'</span>'+
								'</th>'+
								'<th class="js-provinces-table revenue">'+
									'<span class="js-sort-by-revenue b-sort-box"><i></i>'+localization[lang]['revenue']+'</span>'+
								'</th>'+
								'<th style="width:150px;" class="js-provinces-table occupancy_time">'+
									'<span class="js-sort-by-occupancy_time b-sort-box"><i></i>'+localization[lang]['occupancy_time']+'</span>'+
								'</th>'+
							'</tr>'+
						'</thead>'+
						'<tbody id="js-provinces-table-body">'+
							'<tr class="js-template js-hidden">'+
								'<td width="20px" class="">'+
									'<i style="width:24px;height:24px;display:block;" class="js-type js-tooltip"></i>'+
								'</td>'+
								'<td class="js-name">'+
									'<span></span>'+
									'<i style="width:18px;height:18px;display:inline-block;" class="js-hidden js-province-attacked ico-province-'+type+'"></i>'+
									'<i style="width:18px;height:18px;display:inline-block;" class="js-hidden js-province-combats-running ico-province-combats-running"></i>'+
									'<i style="width:18px;height:18px;display:inline-block;" class="js-hidden js-province-capital ico-province-capital"></i>'+
								'</td>'+
								'<td class="js-hidden js-arena_name"></td>'+
								'<td class="js-hidden js-prime_time b-prime-time"></td>'+
								'<td class="js-hidden js-revenue">'+
									'<span class="currency-gold"></span>'+
								'</td>'+
								'<td style="width:150px;" class="js-hidden js-occupancy_time">'+
									'<span></span> '+localization[lang]['occupancy_day']+
								'</td>'+
							'</tr>'+
				'';
				var sum_revenue = 0
				for(var i = 0; i < provincesClan.request_data.total_count; i++){
					var items = provincesClan.request_data.items[i];
					var name = items.name;
					var revenue = items.revenue;
					var iTime = items.prime_time;
					var occupancy_time = items.occupancy_time;
					var arena_name = items.arena_name;
					var type = items.type;
					var id = items.id;
					sum_revenue += revenue;
					
					var prime_time = "- - : - -";
					var timestamp = parseInt(iTime);
					if(timestamp != 0){	
						var date = new Date(timestamp*1000);
						var hours = date.getHours().toString();
						if(hours.length == 1){hours = '0'+hours;}
						var minutes = date.getMinutes().toString();
						if(minutes.length == 1){minutes = '0'+minutes;}
						prime_time = hours+':'+minutes;
					}	
					
					provincesHTML += ''+
						'<tr class="even">'+
							'<td width="20px" class="">'+
								'<i style="width:24px;height:24px;display:block;" class="js-type js-tooltip ico-province-type-'+type+' js-tooltip-id_js-normal-tooltip"></i>'+
							'</td>'+
							'<td class="js-name"><a data-province-id="'+id+'" href="/clanwars/maps/?province='+id+'" class="js-map-province-link">'+arena_name+'</a></td>'+
							'<td class="js-arena_name">'+name+'</td>'+
							'<td class="js-prime_time b-prime-time">'+prime_time+'</td>'+
							'<td class="js-revenue">'+
								'<span class="currency-gold">'+revenue+'</span>'+
							'</td>'+
							'<td style="width:150px;" class="js-occupancy_time">'+
								'<span>'+occupancy_time+'</span> '+localization[lang]['occupancy_day']+
							'</td>'+
						'</tr>'+				
					'';
				}
				provincesHTML += ''+
						'</tbody>'+
					'</table>'+	
					'<p class="b-provinces-general-info" style="text-align:right; padding-top:10px; padding-right:10px;">'+
						localization[lang]['provinces_count']+'&nbsp;<span class="b-provinces-count js-provinces-count">'+provincesClan.request_data.total_count+'</span>'+
						localization[lang]['total_revenue']+'&nbsp;<span class="js-total-revenue currency-gold">'+sum_revenue+'</span>'+
					'</p>'+					
				'';
			}else{
				provincesHTML += ''+	
					'<div class="js-no-battles-msg b-message-warning">'+
						localization[lang]['provinces_no']+
					'</div>'+	
				'';			
			}
			provincesHTML += ''+	
				'</div>'+			
			'';
			provinces.innerHTML = provincesHTML;
			var parentElement = document.getElementById('clans_info_content');
			var theFirstChild = parentElement.firstChild;
			parentElement.insertBefore(provinces, theFirstChild);			
		}	
	}
	
	function onViewBlock(element){
		var idAt = element.getAttribute('id');		
		var classAt = element.getAttribute('class');
		if(classAt == 'block show'){
			$("."+idAt.toString()).animate({height: '0px'}, 500);
			element.setAttribute('class', 'block hide');
			setCookie(idAt.toString(), 'hide');
		}else{
			$("."+idAt.toString()).attr('style', 'height: auto;');	
			element.setAttribute('class', 'block show');
			setCookie(idAt.toString(), 'show');
		}
	}		
	addScript(onViewBlock);	

	function getJson(jsonType){
		var xmlhttp;
		var json;
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
		if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
			xmlhttp = new XMLHttpRequest();
		}
		xmlhttp.open('GET', '/community/clans/'+clanId+'/'+jsonType+'/list/', false);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-javascript; charset=utf-8');
		xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
		xmlhttp.setRequestHeader('Accept', 'application/json, text/javascript, */*; q=0.01');
		xmlhttp.addEventListener('load', function(){
			json = JSON.parse(xmlhttp.responseText);
		});
		xmlhttp.send('id=js-battles-table&source_token='+token);	
		
		return json;
	}	
	
	function addMenuLink(){
		var l_sidebar = document.getElementsByClassName("l-sidebar")[0];
		var menu_link = ''+		
			'<div class="b-context-menu">'+
				'<div class="b-context-menu_wrapper">'+
					'<div class="b-context-menu_arrow"></div>'+
					'<ul class="b-context-menu-list">'+
		'';
		if(host.indexOf(".ru") > -1){
			menu_link += ''+
				'<li class="">'+
					'<a target="_blank" href="http://ivanerr.ru/lt/clan/'+clanId+'">'+localization[lang]['clan']+' ivaner.ru</a>'+
				'</li>'+
				'<li class="">'+
					'<a target="_blank" href="http://wot-news.com/index.php/stat/progress/ru/'+clanId+'">'+localization[lang]['clan']+' wot-news.com</a>'+
				'</li>'+
				'<li class="">'+
					'<a target="_blank" href="http://armor.kiev.ua/wot/clan/'+clanId+'">'+localization[lang]['clan']+' armor.kiev.ua</a>'+
				'</li>'+	
				'<li class="">'+
					'<a target="_blank" href="http://duckandcover.ru/wotka?search=clan&nickname='+clanTag+'&server=RU">'+localization[lang]['clan']+' duckandcover.ru</a>'+
				'</li>'+				
			'';
		}
		if(host.indexOf(".com") > -1){
			menu_link += ''+
				'<li class="">'+
					'<a target="_blank" href="http://wot-news.com/index.php/stat/progress/us/'+clanId+'">'+localization[lang]['clan']+' wot-news.com</a>'+
				'</li>'+
				'<li class="">'+
					'<a target="_blank" href="http://duckandcover.ru/wotka?search=clan&nickname='+clanTag+'&server=NAm">'+localization[lang]['clan']+' duckandcover.ru</a>'+
				'</li>'+					
			'';
		}
		if(host.indexOf(".eu") > -1){
			menu_link += ''+
				'<li class="">'+
					'<a target="_blank" href="http://wot-news.com/index.php/stat/progress/eu/'+clanId+'">'+localization[lang]['clan']+' wot-news.com</a>'+
				'</li>'+
				'<li class="">'+
					'<a target="_blank" href="http://duckandcover.ru/wotka?search=clan&nickname='+clanTag+'&server=EU">'+localization[lang]['clan']+' duckandcover.ru</a>'+
				'</li>'+				
			'';
		}	
		if(host.indexOf(".asia") > -1){
			menu_link += ''+
				'<li class="">'+
					'<a target="_blank" href="http://wot-news.com/index.php/stat/progress/sea/'+clanId+'">'+localization[lang]['clan']+' wot-news.com</a>'+
				'</li>'+
				'<li class="">'+
					'<a target="_blank" href="http://duckandcover.ru/wotka?search=clan&nickname='+clanTag+'&server=SEAs">'+localization[lang]['clan']+' duckandcover.ru</a>'+
				'</li>'+					
			'';
		}		
		if(host.indexOf(".kr") > -1){
			menu_link += ''+
				'<li class="">'+
					'<a target="_blank" href="http://duckandcover.ru/wotka?search=clan&nickname='+clanTag+'&server=KR">'+localization[lang]['clan']+' duckandcover.ru</a>'+
				'</li>'+					
			'';
		}
		menu_link += ''+
					'</ul>'+
				'</div>'+
			'</div>'+
		'';
		
		l_sidebar.innerHTML += menu_link;		
	}
	
	var loading = -1;
	function runCollectionInfo(){
		if(loading == -1){
			loading = 1;
		
			document.getElementById('clans_info_content').innerHTML += ''+
				'<div class="loading_waiting" align="center">'+
					'<img src="/static/3.11.1.2/common/css/block/b-content/img/waiting.gif">'+
					'<div class="loading_waiting_percents">0%</div>'+
					'<br />'+localization[lang]['wait']+
				'</div>'+
			'';
			
			xdr.xget('http://api.'+document.location.host+'/uc/clans/'+clanId+'/api/1.1/?source_token='+token, getClan);
		}		
	}
	
	var ClanArray = [];	
	var countMembers = 0;
	var one_percent = 1;
	function getClan(response){
		var clan = JSON.parse(response);
		countMembers = clan.data.members_count;
		one_percent = 100/countMembers;
		
		var ClanIdArray = []; 
		
		for(var i = 0; i < countMembers; i++){
			var account_id = clan.data.members[i].account_id;
			var account_name = clan.data.members[i].account_name;
			var role = clan.data.members[i].role;
			
			ClanArray[account_name] = account_id;
			ClanArray[account_id] = [];			
			ClanArray[account_id]['name'] = account_name;
			ClanArray[account_id]['role'] = role;
			
			ClanIdArray[i] = account_id;
		}
		
		xdr.xget('http://walkure.su/US_ClanInfo/index.php?type=get&clanId='+clanId, getSaveCompany);
		
		setTimeout(function(){getMembersTask(0, ClanIdArray)}, 100);		
	}
	
	var saveCompany;
	function getSaveCompany(response){
		saveCompany = eval('(' + response + ')');
	}

	var task = 0;
	function getMembersTask(i, ClanIdArray){
		if(task < maxtask){
			if(ClanIdArray[i] !== undefined){
				task++;			
				xdr.xget('http://api.'+document.location.host+'/uc/accounts/'+ClanIdArray[i]+'/api/1.9/?source_token='+token, getMembers);
				setTimeout(function(){getMembersTask(i + 1, ClanIdArray)}, 100);
			}
		}else{
			setTimeout(function(){getMembersTask(i, ClanIdArray)}, 100);	
		}		
	}

	var MembersArray = [];
	var RatingsArray = [];
	RatingsArray['gr'] = [];
	RatingsArray['wb'] =  [];
	RatingsArray['eb'] = [];
	RatingsArray['win'] = [];
	RatingsArray['gpl'] = [];
	RatingsArray['cpt'] = [];
	RatingsArray['dmg'] = [];
	RatingsArray['dpt'] = [];
	RatingsArray['frg'] = [];
	RatingsArray['spt'] = [];
	RatingsArray['exp'] = [];
	var TankArray = [];
	TankArray['lightTank'] = [];
	TankArray['mediumTank'] = []; 
	TankArray['heavyTank'] = []; 
	TankArray['AT-SPG'] = []; 
	TankArray['SPG'] = [];
	for(var lvlI = 0; lvlI < 10; lvlI++){
		TankArray['lightTank'][lvlI+1] = [];
		TankArray['mediumTank'][lvlI+1] = [];
		TankArray['heavyTank'][lvlI+1] = [];
		TankArray['AT-SPG'][lvlI+1] = [];
		TankArray['SPG'][lvlI+1] = [];
	}	
	var index = -1;
	var progress = 0;
	function getMembers(response){		
		task--;
		index++;
		
		var player = JSON.parse(response);
		
		progress++;
		var loading_waiting_percents = document.getElementsByClassName("loading_waiting_percents")[0];
		loading_waiting_percents.innerHTML = Math.ceil(one_percent * progress) + '%';		
			
		var account_id = ClanArray[player.data.name];
		var name = player.data.name;
		
		MembersArray[index] = [];
		MembersArray[index]['id'] = account_id;
		MembersArray[index]['name'] = name;
		MembersArray[index]['role'] = getNumerRole(player.data.clan.member.role);
		MembersArray[index]['day'] = Math.floor(((((new Date()).getTime())/1000) - player.data.clan.member.since)/86400);
		
		if(saveCompany != null){
			MembersArray[index]['company'] = saveCompany[MembersArray[index]['id']];
		}else{
			MembersArray[index]['company'] = '0';
		}
		
		var battles = player.data.ratings.battles.value;
		var damage = player.data.ratings.damage_dealt.value/battles;
		var winrate = 100/(battles/player.data.ratings.battle_wins.value);
		var hits_percents = player.data.battles.hits_percents;
		var survived_percents = player.data.summary.survived_battles/(player.data.summary.battles_count/100);
		
		var txtBattles = battles; if(isNaN(Math.ceil(battles))){txtBattles = 0;}
		MembersArray[index]['battles'] = txtBattles;
		
		var txtDamage = damage; if(isNaN(Math.ceil(damage))){txtDamage = 0;}
		MembersArray[index]['damage'] = txtDamage;
		
		var txtWinrate = winrate; if(isNaN(Math.ceil(winrate))){txtWinrate = 0;}
		MembersArray[index]['winrate'] = txtWinrate;
		
		var txtHitsPercents = hits_percents; if(isNaN(Math.ceil(hits_percents))){txtHitsPercents = 0;}
		MembersArray[index]['hits_percents'] = txtHitsPercents;
		
		var txtSurvivedPercents = survived_percents; if(isNaN(Math.ceil(survived_percents))){txtSurvivedPercents = 0;}
		MembersArray[index]['survived_percents'] = txtSurvivedPercents;
		
		MembersArray[index]['vehicles'] = [];
			MembersArray[index]['vehicles']['lightTank'] = [];
			MembersArray[index]['vehicles']['mediumTank'] = []; 
			MembersArray[index]['vehicles']['heavyTank'] = []; 
			MembersArray[index]['vehicles']['AT-SPG'] = []; 
			MembersArray[index]['vehicles']['SPG'] = [];
			
		var BattleLevelArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
		var vehicles = player.data.vehicles;
		var key, count = 0;
		for(key in vehicles){if(vehicles.hasOwnProperty(key)){count++;}}
		for(var vI = 0; vI < count; vI++){
			BattleLevelArray[vehicles[vI].level] += parseInt(vehicles[vI].battle_count);
			
			if(vehicles[vI].class == 'lightTank'){
				MembersArray[index]['vehicles']['lightTank'][MembersArray[index]['vehicles']['lightTank'].length] = vehicles[vI].level+'<@>'+vehicles[vI].nation+'<@>'+vehicles[vI].localized_name+'<@>'+vehicles[vI].image_url+'<@>'+vehicles[vI].battle_count+'<@>'+vehicles[vI].win_count+'<@>'+vehicles[vI].survivedBattles+'<@>'+vehicles[vI].damageDealt;
				if(undefined == TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]){
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name] = [];
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]['count'] = 1;
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]['nation'] = vehicles[vI].nation;
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]['url'] = vehicles[vI].image_url;
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]['members'] = name;
				}else{
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]['count']++;
					TankArray['lightTank'][vehicles[vI].level][vehicles[vI].localized_name]['members'] += ', ' + name ;
				}
			}
			if(vehicles[vI].class == 'mediumTank'){
				MembersArray[index]['vehicles']['mediumTank'][MembersArray[index]['vehicles']['mediumTank'].length] = vehicles[vI].level+'<@>'+vehicles[vI].nation+'<@>'+vehicles[vI].localized_name+'<@>'+vehicles[vI].image_url+'<@>'+vehicles[vI].battle_count+'<@>'+vehicles[vI].win_count+'<@>'+vehicles[vI].survivedBattles+'<@>'+vehicles[vI].damageDealt;
				if(undefined == TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]){
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name] = [];
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]['count'] = 1;
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]['nation'] = vehicles[vI].nation;
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]['url'] = vehicles[vI].image_url;
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]['members'] = name;
				}else{
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]['count']++;
					TankArray['mediumTank'][vehicles[vI].level][vehicles[vI].localized_name]['members'] += ', ' + name ;
				}
			}
			if(vehicles[vI].class == 'heavyTank'){
				MembersArray[index]['vehicles']['heavyTank'][MembersArray[index]['vehicles']['heavyTank'].length] = vehicles[vI].level+'<@>'+vehicles[vI].nation+'<@>'+vehicles[vI].localized_name+'<@>'+vehicles[vI].image_url+'<@>'+vehicles[vI].battle_count+'<@>'+vehicles[vI].win_count+'<@>'+vehicles[vI].survivedBattles+'<@>'+vehicles[vI].damageDealt;				
				if(undefined == TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]){
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name] = [];
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]['count'] = 1;
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]['nation'] = vehicles[vI].nation;
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]['url'] = vehicles[vI].image_url;
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]['members'] = name;
				}else{
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]['count']++;
					TankArray['heavyTank'][vehicles[vI].level][vehicles[vI].localized_name]['members'] += ', ' + name ;
				}			
			}
			if(vehicles[vI].class == 'AT-SPG'){
				MembersArray[index]['vehicles']['AT-SPG'][MembersArray[index]['vehicles']['AT-SPG'].length] = vehicles[vI].level+'<@>'+vehicles[vI].nation+'<@>'+vehicles[vI].localized_name+'<@>'+vehicles[vI].image_url+'<@>'+vehicles[vI].battle_count+'<@>'+vehicles[vI].win_count+'<@>'+vehicles[vI].survivedBattles+'<@>'+vehicles[vI].damageDealt;
				if(undefined == TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]){
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name] = [];
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]['count'] = 1;
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]['nation'] = vehicles[vI].nation;
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]['url'] = vehicles[vI].image_url;
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]['members'] = name;
				}else{
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]['count']++;
					TankArray['AT-SPG'][vehicles[vI].level][vehicles[vI].localized_name]['members'] += ', ' + name ;
				}			
			}
			if(vehicles[vI].class == 'SPG'){
				MembersArray[index]['vehicles']['SPG'][MembersArray[index]['vehicles']['SPG'].length] = vehicles[vI].level+'<@>'+vehicles[vI].nation+'<@>'+vehicles[vI].localized_name+'<@>'+vehicles[vI].image_url+'<@>'+vehicles[vI].battle_count+'<@>'+vehicles[vI].win_count+'<@>'+vehicles[vI].survivedBattles+'<@>'+vehicles[vI].damageDealt;
				if(undefined == TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]){
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name] = [];
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]['count'] = 1;
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]['nation'] = vehicles[vI].nation;
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]['url'] = vehicles[vI].image_url;
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]['members'] = name;
				}else{
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]['count']++;
					TankArray['SPG'][vehicles[vI].level][vehicles[vI].localized_name]['members'] += ', ' + name ;
				}			
			}
		}
		
		var des = player.data.ratings.frags.value/battles;
		var det = player.data.ratings.spotted.value/battles;
		var cap = player.data.ratings.ctf_points.value/battles;
		var def = player.data.ratings.dropped_ctf_points.value/battles;
		var mid = (1*BattleLevelArray[1]/battles)+(2*BattleLevelArray[2]/battles)+(3*BattleLevelArray[3]/battles)
			+(4*BattleLevelArray[4]/battles)+(5*BattleLevelArray[5]/battles)+(6*BattleLevelArray[6]/battles)+(7*BattleLevelArray[7]/battles)
			+(8*BattleLevelArray[8]/battles)+(9*BattleLevelArray[9]/battles)+(10*BattleLevelArray[10]/battles);
		
		Math.logb = function(number, base){return Math.log(number)/Math.log(base);};
		
		var kpd = (damage*(10/(mid+2))*(0.23 + 2*mid/100))+(des*250)+(det*150)+(Math.logb(cap+1,1.732)*150)+(def*150);
		var txtKpd = kpd; if(isNaN(Math.ceil(kpd))){txtKpd = 0;}
		MembersArray[index]['kpd'] = txtKpd;
		
		var wn6 = (1240-1040/Math.pow(Math.min(mid, 6),0.164))*des+damage*530/(184*Math.exp(0.24*mid)+130)+det*125+Math.min(def,2.2)*100+((185/(0.17+Math.exp((winrate-35)*-0.134)))-500)*0.45+(6-Math.min(mid,6))*-60;
		var txtWn6 = wn6; if(isNaN(Math.ceil(wn6))){txtWn6 = 0;}
		MembersArray[index]['wn6'] = txtWn6;
		
		var cf_xp = player.data.ratings.xp.value/battles;
		var wins = player.data.ratings.battle_wins.value/battles;
		
		var bs = Math.log(battles)/10*(cf_xp*1+damage*(wins*2.0+des*0.9+det*0.5+cap*0.5+def* 0.5));
		var txtBs = bs; if(isNaN(Math.ceil(bs))){txtBs = 0;}
		MembersArray[index]['bs'] = txtBs;
		
		var xeff = 0;
		if(txtKpd < 420){
			xeff = 0;
		}else{
			xeff = Math.max(Math.min(txtKpd*(txtKpd*(txtKpd*(txtKpd*(txtKpd*(0.000000000000000045254*txtKpd - 0.00000000000033131) + 0.00000000094164) - 0.0000013227) + 0.00095664) - 0.2598) + 13.23, 100), 0);
		}
		var txtXeff = xeff; if(isNaN(Math.ceil(xeff))){txtXeff = 0;}
		MembersArray[index]['xeff'] = txtXeff;
		
		var xwn = 0;
		if(wn6 > 2160){
			xwn = 100;
		}else{
			xwn = Math.max(Math.min(txtWn6*(txtWn6*(txtWn6*(-0.00000000001268*txtWn6 + 0.00000005147) - 0.00006418) + 0.07576) - 7.25, 100), 0);
		}
		var txtXwn = xwn; if(isNaN(Math.ceil(xwn))){txtXwn = 0;}
		MembersArray[index]['xwn'] = txtXwn;

		var ratings = player.data.ratings;
		if((RatingsArray['gr']['place'] === undefined || RatingsArray['gr']['place'] > ratings.integrated_rating.place) && ratings.integrated_rating.place != null){
			RatingsArray['gr']['name'] = name;
			RatingsArray['gr']['place'] = ratings.integrated_rating.place;
			RatingsArray['gr']['value'] = ratings.integrated_rating.value;
		}		
		if((RatingsArray['wb']['place'] === undefined || RatingsArray['wb']['place'] > ratings.battle_avg_performance.place) && ratings.battle_avg_performance.place != null){
			RatingsArray['wb']['name'] = name;
			RatingsArray['wb']['place'] = ratings.battle_avg_performance.place;
			RatingsArray['wb']['value'] = ratings.battle_avg_performance.value;
		}		
		if((RatingsArray['eb']['place'] === undefined || RatingsArray['eb']['place'] > ratings.battle_avg_xp.place) && ratings.battle_avg_xp.place != null){
			RatingsArray['eb']['name'] = name;
			RatingsArray['eb']['place'] = ratings.battle_avg_xp.place;
			RatingsArray['eb']['value'] = ratings.battle_avg_xp.value;
		}		
		if((RatingsArray['win']['place'] === undefined || RatingsArray['win']['place'] > ratings.battle_wins.place) && ratings.battle_wins.place != null){
			RatingsArray['win']['name'] = name;
			RatingsArray['win']['place'] = ratings.battle_wins.place;
			RatingsArray['win']['value'] = ratings.battle_wins.value;
		}		
		if((RatingsArray['gpl']['place'] === undefined || RatingsArray['gpl']['place'] > ratings.battles.place) && ratings.battles.place != null){
			RatingsArray['gpl']['name'] = name;
			RatingsArray['gpl']['place'] = ratings.battles.place;
			RatingsArray['gpl']['value'] = ratings.battles.value;
		}		
		if((RatingsArray['cpt']['place'] === undefined || RatingsArray['cpt']['place'] > ratings.ctf_points.place) && ratings.ctf_points.place != null){
			RatingsArray['cpt']['name'] = name;
			RatingsArray['cpt']['place'] = ratings.ctf_points.place;
			RatingsArray['cpt']['value'] = ratings.ctf_points.value;
		}		
		if((RatingsArray['dmg']['place'] === undefined || RatingsArray['dmg']['place'] > ratings.damage_dealt.place) && ratings.damage_dealt.place != null){
			RatingsArray['dmg']['name'] = name;
			RatingsArray['dmg']['place'] = ratings.damage_dealt.place;
			RatingsArray['dmg']['value'] = ratings.damage_dealt.value;
		}		
		if((RatingsArray['dpt']['place'] === undefined || RatingsArray['dpt']['place'] > ratings.dropped_ctf_points.place) && ratings.dropped_ctf_points.place != null){
			RatingsArray['dpt']['name'] = name;
			RatingsArray['dpt']['place'] = ratings.dropped_ctf_points.place;
			RatingsArray['dpt']['value'] = ratings.dropped_ctf_points.value;
		}		
		if((RatingsArray['frg']['place'] === undefined || RatingsArray['frg']['place'] > ratings.frags.place) && ratings.frags.place != null){
			RatingsArray['frg']['name'] = name;
			RatingsArray['frg']['place'] = ratings.frags.place;
			RatingsArray['frg']['value'] = ratings.frags.value;
		}		
		if((RatingsArray['spt']['place'] === undefined || RatingsArray['spt']['place'] > ratings.spotted.place) && ratings.spotted.place != null){
			RatingsArray['spt']['name'] = name;
			RatingsArray['spt']['place'] = ratings.spotted.place;
			RatingsArray['spt']['value'] = ratings.spotted.value;
		}		
		if((RatingsArray['exp']['place'] === undefined || RatingsArray['exp']['place'] > ratings.xp.place) && ratings.xp.place != null){
			RatingsArray['exp']['name'] = name;	
			RatingsArray['exp']['place'] = ratings.xp.place;	
			RatingsArray['exp']['value'] = ratings.xp.value;
		}				
		
		if(countMembers == progress){UpdatePage();}
	}	
	
	var error_message = '';
	function onError(url){
		var info = (url.split('/'))[4];
		if(info == 'clans'){
			wg.message_box(
				localization[lang]['box'], 
				localization[lang]['errorClan'], 
				{confirm:{text: "OK", click: function(){}}}
			);			
		}else if(info == 'accounts'){
			task--;
			index++;
			
			if(countMembers == index && index == progress){return;}
			
			progress++;
			var loading_waiting_percents = document.getElementsByClassName("loading_waiting_percents")[0];
			loading_waiting_percents.innerHTML = Math.ceil(one_percent * progress) + '%';
			
			var account_id = (url.split('/'))[5];
			if(error_message != ''){error_message += ', ';}
			error_message += ClanArray[account_id]['name'];
			
			MembersArray[index] = [];
			MembersArray[index]['id'] = account_id;
			MembersArray[index]['name'] = ClanArray[account_id]['name'];
			MembersArray[index]['role'] = getNumerRole(ClanArray[account_id]['role']);
			MembersArray[index]['day'] = 0;
			MembersArray[index]['battles'] = 0;
			MembersArray[index]['damage'] = 0;
			MembersArray[index]['winrate'] = 0;
			MembersArray[index]['hits_percents'] = 0;
			MembersArray[index]['survived_percents'] = 0;		
			MembersArray[index]['vehicles'] = [];
				MembersArray[index]['vehicles']['lightTank'] = [];
				MembersArray[index]['vehicles']['mediumTank'] = []; 
				MembersArray[index]['vehicles']['heavyTank'] = []; 
				MembersArray[index]['vehicles']['AT-SPG'] = []; 
				MembersArray[index]['vehicles']['SPG'] = [];
			MembersArray[index]['kpd'] = 0;
			MembersArray[index]['wn6'] = 0;
			MembersArray[index]['bs'] = 0;
			MembersArray[index]['xeff'] = 0;
			MembersArray[index]['xwn'] = 0;			
			
			if(countMembers == progress){UpdatePage();}
		}
	}
	
	function UpdatePage(){
		if(error_message  != ''){
			wg.message_box(
				localization[lang]['box'], 
				localization[lang]['error_message'] + error_message + '.', 
				{confirm:{text: "OK", click: function(){}}}
			);			
		}	

		MembersArray.sort(DESC('kpd'));
		var table = CreateTableClan();
		
		CreateStatClan();
		CreateVehicleClan();
		CreateRatingClan();
				
		document.getElementById('clans_info_content').appendChild(table);
		document.getElementsByClassName("loading_waiting")[0].style.display = 'none';		
		document.getElementsByClassName("showclaninfo")[0].style.display = 'block';	

		memberTable.Update();
	}
	
	function CreateRatingClan(){
		var rating_block_class = 'block';
		var rating_block_height = '0px';
		var block_rating_head = getCookie('rating_head');
		if(null == block_rating_head){
			rating_block_class += ' show';
			rating_block_height = 'auto';
		}else{
			rating_block_class += ' '+block_rating_head;
			if(block_rating_head == 'hide'){rating_block_height = '0px';}else{rating_block_height = 'auto';}
		}
	
		var ratingall = document.createElement('div');
		ratingall.setAttribute('id', 'ratingall');
		ratingall.setAttribute('style', 'margin-bottom: 20px;');
		ratingall.innerHTML = ''+
			'<div id="rating_head_block">'+
				'<span id="rating_head" class="'+rating_block_class+'" onclick="onViewBlock(this);">'+
					localization[lang]['rating_head_block']+
				'</span>'+
			'</div>'+			
			'<div class="b-user-block b-speedometer-wrpr rating_head style_block" style="height: '+rating_block_height+';">'+
				'<div align="center" class="b-head-block style_block_head">'+
					'<h3>'+localization[lang]['rating_head']+'</h3>'+
				'</div>'+
				'<table class="t-profile ratingall" cellspacing="0" cellpadding="0">'+
					'<tbody>'+
						'<tr>'+
							'<th colspan="2">'+
								localization[lang]['rating']+
							'</th>'+
							'<th class="t-right">'+
								localization[lang]['name']+
							'</th>'+
							'<th class="t-right">'+
								localization[lang]['value']+
							'</th>'+
							'<th class="t-right">'+
								localization[lang]['place']+
							'</th>'+
						'</tr>'+
						getRatingsTable('gr', localization[lang]['gr'], RatingsArray['gr']['name'], RatingsArray['gr']['value'], RatingsArray['gr']['place'])+
						getRatingsTable('wb', localization[lang]['wb'], RatingsArray['wb']['name'], RatingsArray['wb']['value'], RatingsArray['wb']['place'])+
						getRatingsTable('eb', localization[lang]['eb'], RatingsArray['eb']['name'], RatingsArray['eb']['value'], RatingsArray['eb']['place'])+
						getRatingsTable('win', localization[lang]['win'], RatingsArray['win']['name'], RatingsArray['win']['value'], RatingsArray['win']['place'])+
						getRatingsTable('gpl', localization[lang]['gpl'], RatingsArray['gpl']['name'], RatingsArray['gpl']['value'], RatingsArray['gpl']['place'])+
						getRatingsTable('cpt', localization[lang]['cpt'], RatingsArray['cpt']['name'], RatingsArray['cpt']['value'], RatingsArray['cpt']['place'])+
						getRatingsTable('dmg', localization[lang]['dmg'], RatingsArray['dmg']['name'], RatingsArray['dmg']['value'], RatingsArray['dmg']['place'])+
						getRatingsTable('dpt', localization[lang]['dpt'], RatingsArray['dpt']['name'], RatingsArray['dpt']['value'], RatingsArray['dpt']['place'])+
						getRatingsTable('frg', localization[lang]['frg'], RatingsArray['frg']['name'], RatingsArray['frg']['value'], RatingsArray['frg']['place'])+
						getRatingsTable('spt', localization[lang]['spt'], RatingsArray['spt']['name'], RatingsArray['spt']['value'], RatingsArray['spt']['place'])+
						getRatingsTable('exp', localization[lang]['exp'], RatingsArray['exp']['name'], RatingsArray['exp']['value'], RatingsArray['exp']['place'])+
					'</tbody>'+
				'</table>'+
			'</div>'+				
		'';
		document.getElementById('clans_info_content').appendChild(ratingall);			
	}	

	function getRatingsTable(img_name, ratings_name, name, value, place){
		var rating = ''+
			'<tr>'+
				'<td class="t-rate-ico" style="padding: 3px 0px 3px 14px;">'+
					'<img src="/static/3.12.0.3/common/img/ratings/small/'+img_name+'.png">'+
				'</td>'+
				'<td class="t-headminor" style="padding: 8px 14px;">'+
					ratings_name+
				'</td>'+
				'<td class="t-right" style="padding: 8px 14px;">'+
					name+
				'</td>'+
				'<td class="t-right" style="padding: 8px 14px;">'+
					breakNumer(value)+
				'</td>'+
				'<td class="t-right" style="padding: 8px 14px;">'+
					breakNumer(place)+
				'</td>'+
			'</tr>';
		return rating;
	}

	function breakNumer(numer){
		if(numer === undefined){numer = '0';}else{numer = numer.toString();}
		var newnumer = '';
		var symbol = 0;;
		for(var i = numer.length; i > 0; i--){
			if(symbol < 3){
				newnumer = numer[i-1]+newnumer;
				symbol++;
			}else{
				newnumer = numer[i-1]+' '+newnumer;
				symbol = 1;
			}
		}
		return newnumer;
	}
	
	function CreateVehicleClan(){	
		var vehicle_block_class = 'block';
		var vehicle_block_height = '0px';
		var block_vehicle_head = getCookie('vehicle_head');
		if(null == block_vehicle_head){
			vehicle_block_class += ' show';
			vehicle_block_height = 'auto';
		}else{
			vehicle_block_class += ' '+block_vehicle_head;
			if(block_vehicle_head == 'hide'){vehicle_block_height = '0px';}else{vehicle_block_height = 'auto';}
		}	
	
		var vehicleall = document.createElement('div');
		vehicleall.setAttribute('id', 'vehicleall');
		vehicleall.setAttribute('style', 'margin-bottom: 20px;');
		vehicleall.innerHTML = ''+
			'<div id="vehicle_head_block">'+
				'<span id="vehicle_head" class="'+vehicle_block_class+'" onclick="onViewBlock(this);">'+
					localization[lang]['vehicle_head_block']+
				'</span>'+
			'</div>'+			
			'<div class="b-user-block b-speedometer-wrpr vehicle_head style_block" style="height: '+vehicle_block_height+';">'+
				'<div align="center" class="b-head-block style_block_head">'+
					'<h3>'+localization[lang]['vehicle_head']+'</h3>'+
				'</div>'+
				'<div class="vehiclesclan" style="border: 1px solid #2E3139;">'+
					'<div id="vehicles_hide" company="absolute" class="rote" style="cursor: pointer;">'+localization[lang]['absolute']+'<div align="right" style="float:right;"></div></div>'+
					'<div id="absolute" style="display: none;"></div>'+
				'</div>'+
				'<div class="vehiclesclan" style="border: 1px solid #2E3139;">'+
					'<div id="vehicles_hide" company="championship" class="rote" style="cursor: pointer;">'+localization[lang]['championship']+'<div align="right" style="float:right;"></div></div>'+
					'<div id="championship" style="display: none;"></div>'+
				'</div>'+
				'<div class="vehiclesclan" style="border: 1px solid #2E3139;">'+
					'<div id="vehicles_hide" company="average" class="rote" style="cursor: pointer;">'+localization[lang]['average']+'<div align="right" style="float:right;"></div></div>'+
					'<div id="average" style="display: none;"></div>'+
				'</div>'+
				'<div class="vehiclesclan" style="border: 1px solid #2E3139;">'+
					'<div id="vehicles_hide" company="junior" class="rote" style="cursor: pointer;">'+localization[lang]['junior']+'<div align="right" style="float:right;"></div></div>'+
					'<div id="junior" style="display: none;"></div>'+
				'</div>'+				
			'</div>'+
		'';
		document.getElementById('clans_info_content').appendChild(vehicleall);
		
		var rote = document.getElementsByClassName("rote");
		for(var i = 0; i < rote.length; i++){
			if(rote[i].addEventListener){
				rote[i].addEventListener('click', function(e){onViewVehiclesClan(e.target);}, false);
			}else{
				rote[i].attachEvent('onclick', function(e){onViewVehiclesClan(e.target);});
			}
		}		
	}

	function onViewVehiclesClan(element){
		var company = element.getAttribute('company');
		var status = element.getAttribute('id');
		var vehiclesContent = document.getElementById(company);
		
		if(status == 'vehicles_hide'){
			element.setAttribute('id', 'vehicles_show');
			vehiclesContent.innerHTML = getVehicleClan(company);
			vehiclesContent.setAttribute('style', 'display: block;');		
		}else{
			element.setAttribute('id', 'vehicles_hide');
			vehiclesContent.setAttribute('style', 'display: none;');
		}
		
		var tooltip2 = document.getElementsByClassName("tooltip2");
		for(var i = 0; i < tooltip2.length; i++){
			if(tooltip2[i].addEventListener){
				tooltip2[i].addEventListener('click', function(e){onViewMembersTank(e.target);}, false);
			}else{
				tooltip2[i].attachEvent('onclick', function(e){onViewMembersTank(e.target);});
			}
		}			
	}
	
	function onViewMembersTank(element){
		var type = element.getAttribute('type');
		var level = element.getAttribute('level');
		var key = element.getAttribute('key');	
		var urlSplit = TankArray[type][level][key]['url'].split('/');
		var newUrl = '';
		for(var s = 0; s < urlSplit.length; s++){
			if(urlSplit[s] != 'small'){
				newUrl += urlSplit[s];
				if(s != (urlSplit.length - 1)){
					newUrl += '/';
				}
			}
		}
		
		var members_yes = TankArray[type][level][key]['members'];
		var members_no = '';
		var members_yes_split = TankArray[type][level][key]['members'].split(', ');
		for(var n = 0; n < MembersArray.length; n++){
			if(find(members_yes_split, MembersArray[n]['name']) == -1){
				if(members_no != ''){members_no += ', ';}
				members_no += MembersArray[n]['name'];
			}
		}
		
		var members_tank_title = document.getElementsByClassName("members-tank-title")[0];
		var members_tank_content = document.getElementsByClassName("members-tank-content")[0];
		
		members_tank_title.innerHTML = localization[lang]['tank']+': '+key;
		members_tank_content.innerHTML = ''+
			'<div class="b-img-text_img b-img-text_img_slot" style="float:left; padding-right: 10px;"><img src="'+newUrl+'" alt="'+key+'" /></div>'+
			'<div style="width: 400px; float: right;">'+
				'<p><b><font color="green">'+localization[lang]['yes_tank']+':</font></b> '+members_yes+'.</p>'+
				'<p><b><font color="red">'+localization[lang]['no_tank']+':</font></b> '+members_no+'.</p>'+
			'</div>'+
		'';
		
		document.getElementsByClassName("members-tank")[0].style.display = 'block';
	}		

	function getVehicleClan(company){
		var html = '<table class="vehicleall">';
		var level = 0;
		if('absolute' == company){level = 10;}
		if('championship' == company){level = 8;}
		if('average' == company){level = 6;}
		if('junior' == company){level = 4;}
		
		for(var tI = 0; tI < 5; tI++){
			var type = ''; var count = 0; var img = '';
			if(tI == 0){type = 'lightTank'}
			if(tI == 1){type = 'mediumTank'}
			if(tI == 2){type = 'heavyTank'}
			if(tI == 3){type = 'AT-SPG'}
			if(tI == 4){type = 'SPG'}
			
			for(var key in TankArray[type][level]){
				img += ''+
					'<div style="background:url(/static/3.12.0.3/common/img/nation/'+TankArray[type][level][key]['nation']+'.png) no-repeat; float: left;">'+
						'<a class="tooltip2" type="'+type+'" level="'+level+'" key="'+key+'">'+
							'<img src="'+TankArray[type][level][key]['url']+'" class="img_tank" type="'+type+'" level="'+level+'" key="'+key+'">'+
							'<span class="classic">'+
								'<b>'+localization[lang]['tank']+': '+key+'<br />'+
							'</span>'+
						'</a>'+	
						'<div class="b-achivements_wrpr count">'+
							'<span class="b-achivements_num">'+
								'<span>'+TankArray[type][level][key]['count']+'</span>'+
							'</span>'+
						'</div>'+						
					'</div>';						
				count += TankArray[type][level][key]['count'];
			
			}
			
			html += ''+
				'<tr>'+
					'<td class="name_tank_block">'+
						localization[lang][type]+
						'<div class="b-achivements_wrpr count_tank"><span class="b-achivements_num"><span>'+count+'</span></span></div>'+
					'</td>'+
					'<td class="img_tank_block">'+
						img+
					'</td>'+
				'</tr>';		
		}
		
		html += '</table>';
		return html;
	}		
	
	function CreateStatClan(){
		var cf_damage = (sum_damage/sum_count).toFixed(0);
		var cf_win = (sum_win/sum_count).toFixed(2);
		var cf_hit = (sum_hit/sum_count).toFixed(1);
		var cf_survival = (sum_survival/sum_count).toFixed(1);
		var cf_kpd = (sum_kpd/sum_count).toFixed(0);
		var cf_wn6 = (sum_wn6/sum_count).toFixed(0);
		var cf_bs = (sum_bs/sum_count).toFixed(0);
		var cf_xeff = (sum_xeff/sum_count).toFixed(1);
		var cf_xwn = (sum_xwn/sum_count).toFixed(1);
		
		var stat_block_class = 'block';
		var stat_block_height = '0px';
		var block_cf_head = getCookie('cf_head');
		if(null == block_cf_head){
			stat_block_class += ' show';
			stat_block_height = 'auto';
		}else{
			stat_block_class += ' '+block_cf_head;
			if(block_cf_head == 'hide'){stat_block_height = '0px';}else{stat_block_height = 'auto';}
		}
		
		var statall = document.createElement('div');
		statall.setAttribute('id', 'statall');
		statall.setAttribute('style', 'margin-bottom: 20px;');
		statall.innerHTML = ''+
			'<div id="cf_head_block">'+
				'<span id="cf_head" class="'+stat_block_class+'" onclick="onViewBlock(this);">'+
					localization[lang]['cf_head_block']+
				'</span>'+
			'</div>'+
			'<div class="b-user-block b-speedometer-wrpr cf_head style_block" style="height: '+stat_block_height+';">'+
				'<div align="center" class="b-head-block style_block_head">'+
					'<h3>'+localization[lang]['cf_head']+'</h3>'+
				'</div>'+
				'<table class="statall">'+
					'<tr>'+					
						'<td class="head">'+localization[lang]['win']+'</td>'+
						'<td class="head">'+localization[lang]['survivalsum']+'</td>'+
						'<td class="head">'+localization[lang]['damage']+'</td>'+
						'<td class="head">'+localization[lang]['hits_percents']+'</td>'+						
						'<td class="head">'+localization[lang]['kpd']+'</td>'+						
						'<td class="head">'+localization[lang]['wn6']+'</td>'+
						'<td class="head">'+localization[lang]['bs']+'</td>'+
					'</tr>'+
					'<tr>'+
						'<td class="count img2" style="color:'+getAvgColor(cf_win)+';">'+
							cf_win+'%'+
						'</td>'+
						'<td class="count img2">'+
							cf_survival+'%'+
						'</td>'+						
						'<td class="count img1">'+
							cf_damage+''+
						'</td>'+
						'<td class="count img2">'+
							cf_hit+'%'+
						'</td>'+
						'<td class="count img3">'+
							'<font color="'+getXVMColor(cf_xeff)+'">'+cf_xeff+'</font> '+
							'(<font color="'+getKpdColor(cf_kpd)+'">'+cf_kpd+'</font>)'+
						'</td>'+						
						'<td class="count img3">'+
							'<font color="'+getXVMColor(cf_xwn)+'">'+cf_xwn+'</font> '+
							'(<font color="'+getWn6Color(cf_wn6)+'">'+cf_wn6+'</font>)'+
						'</td>'+
						'<td class="count img3">'+
							cf_bs+
						'</td>'+
					'</tr>'+	
				'</table>'+
			'</div>'+
		'';	
		document.getElementById('clans_info_content').appendChild(statall);		
	}	

	var sum_damage = 0;
	var sum_win = 0;
	var sum_hit = 0;
	var sum_survival = 0;
	var sum_kpd = 0; 
	var sum_wn6 = 0; 
	var sum_bs = 0; 
	var sum_xeff = 0; 
	var sum_xwn = 0;
	var sum_count = 0;	
	function CreateTableClan(){
		var js_send_message_button = document.getElementById("js-send-message-button");
		var js_change_roles_button = document.getElementById("js-change-roles-button");
		// js_send_message_button = 1;
		// js_change_roles_button = 1;
	
		var table = document.createElement('table');
		table.setAttribute('id', 'newtableclaninfo');
		table.setAttribute('class', 't-table');
		
		if(js_send_message_button != null && js_change_roles_button != null){
			var caption = document.createElement('caption');
			caption.setAttribute('style', 'text-align:right;');
			caption.innerHTML = ''+
				'<div id="caption" class="b-big-orange-buttonarea b-big-orange-tab">'+
					'<span class="b-big-orange-button" style="height: 26px;">'+
						'<span class="b-big-orange-button_right b-button-wrap" style="height: 26px;">'+
							'<input class="save_clan" type="submit" value="'+localization[lang]['save_clan']+'" style="padding: 2px 5px 0px; height: 26px;">'+
						'</span>'+
					'</span>'+
				'</div>'+
			'';	
			if(caption.addEventListener){
				caption.addEventListener('click', function(){onCompanyClan();}, false);
			}else{
				caption.attachEvent('onclick', function(){onCompanyClan();});
			}		
			table.appendChild(caption);
		}

		var thead = document.createElement('thead');
		var tr_head = document.createElement('tr');	
		getHeadTable(false, 'numer', 'padding-left: 5px; padding-right: 5px;', false, tr_head);
		getHeadTable(true, 'name', false, false, tr_head);		
		getHeadTable(true, 'role', false, false, tr_head);
		getHeadTable(true, 'company', false, false, tr_head);
		getHeadTable(true, 'day', false, false, tr_head);		
		getHeadTable(true, 'battles', false, false, tr_head);		
		getHeadTable(true, 'winrate', false, false, tr_head);		
		getHeadTable(true, 'survived_percents', false, false, tr_head);		
		getHeadTable(true, 'damage', false, false, tr_head);			
		getHeadTable(true, 'hits_percents', false, false, tr_head);	
		getHeadTable(true, 'kpd', false, 'desc', tr_head);		
		getHeadTable(true, 'wn6', false, false, tr_head);
		getHeadTable(true, 'bs', false, false, tr_head);
		getHeadTable(false, 'space', 'padding-left: 5px; padding-right: 5px;', false, tr_head);			
		thead.appendChild(tr_head);
		table.appendChild(thead);

		sum_count = MembersArray.length;

		var tbody = document.createElement('tbody');
		for(var i = 0; i < MembersArray.length; i++){
			var tr = document.createElement('tr');
			for(var j = 0; j < 14; j++){
				var td = document.createElement('td');
				if(j == 0){
					td.setAttribute('style', 'padding-left: 5px; padding-right: 5px;');
					td.innerHTML = i + 1;
				}
				if(j == 1){
					td.setAttribute('class', 't-name');
					td.setAttribute('style', 'white-space: nowrap;');
					td.innerHTML = '<b><a href="/community/accounts/'+MembersArray[i]['id']+'/">'+MembersArray[i]['name']+'</a></b>';
				}
				if(j == 2){					
					td.setAttribute('style', 'white-space: nowrap;');
					td.innerHTML = getRole(MembersArray[i]['role']);
				}				
				if(j == 3){
					var viewCompany = MembersArray[i]['company'];
					var selectedCompany = ['', '', '', '', '', ''];
					switch(MembersArray[i]['company']){
						case '99':
							viewCompany = localization[lang]['stock'];
							selectedCompany[0] = 'selected';
						break
						case '1':
							viewCompany = '1 '+localization[lang]['rota'];
							selectedCompany[1] = 'selected';
						break
						case '2':
							viewCompany = '2 '+localization[lang]['rota'];
							selectedCompany[2] = 'selected';
						break
						case '3':
							viewCompany = '3 '+localization[lang]['rota'];
							selectedCompany[3] = 'selected';
						break;
						case '4':
							viewCompany = '4 '+localization[lang]['rota'];
							selectedCompany[4] = 'selected';
						break
						case '5':
							viewCompany = '5 '+localization[lang]['rota'];
							selectedCompany[5] = 'selected';
						break;
						default:
							viewCompany = localization[lang]['stock'];
							selectedCompany[0] = 'selected';
						break
					}
					if(js_send_message_button != null && js_change_roles_button != null){
						td.innerHTML = ''+
						'<div style="float:right;">'+
							'<select id="'+MembersArray[i]['id']+'" class="company">'+
								'<option value="99" '+selectedCompany[0]+'>'+localization[lang]['stock']+'</option>'+
								'<option value="1" '+selectedCompany[1]+'>1 '+localization[lang]['rota']+'</option>'+
								'<option value="2" '+selectedCompany[2]+'>2 '+localization[lang]['rota']+'</option>'+
								'<option value="3" '+selectedCompany[3]+'>3 '+localization[lang]['rota']+'</option>'+
								'<option value="4" '+selectedCompany[4]+'>4 '+localization[lang]['rota']+'</option>'+
								'<option value="5" '+selectedCompany[5]+'>5 '+localization[lang]['rota']+'</option>'+
							'</select>'+
						'</div>';
					}else if(js_send_message_button != null){
						td.innerHTML = '<div style="float:right;">'+viewCompany+'</div>';
					}
				}
				if(j == 4){
					td.innerHTML = '<div style="float:right;">'+MembersArray[i]['day']+'</div>';
				}
				if(j == 5){
					td.innerHTML = '<div style="float:right;">'+MembersArray[i]['battles']+'</div>';
					if(MembersArray[i]['battles'] < 100){sum_count--;}
				}
				if(j == 6){
					td.setAttribute('style', 'color: '+getAvgColor(MembersArray[i]['winrate'])+';');
					td.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[i]['winrate'])+'%</div>';
					sum_win += MembersArray[i]['winrate'];	
				}
				if(j == 7){
					td.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[i]['survived_percents'])+'%</div>';
					sum_survival += MembersArray[i]['survived_percents'];
				}
				if(j == 8){
					td.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[i]['damage'])+'</div>';
					sum_damage += MembersArray[i]['damage'];					
				}
				if(j == 9){
					td.innerHTML = '<div style="float:right;">'+MembersArray[i]['hits_percents']+'%</div>';
					sum_hit += MembersArray[i]['hits_percents'];
				}
				if(j == 10){
					td.setAttribute('style', 'color: '+getXVMColor(MembersArray[i]['xeff'])+';');
					td.innerHTML = '<div style="float:left;"><b>'+Math.ceil(MembersArray[i]['xeff'])+'</b></div><div style="float:right;">'+Math.ceil(MembersArray[i]['kpd'])+'</div>';
					sum_kpd += MembersArray[i]['kpd'];
					sum_xeff += MembersArray[i]['xeff'];
				}
				if(j == 11){
					td.setAttribute('style', 'color: '+getXVMColor(MembersArray[i]['xwn'])+';');
					td.innerHTML = '<div style="float:left;"><b>'+Math.ceil(MembersArray[i]['xwn'])+'</b></div><div style="float:right;">'+Math.ceil(MembersArray[i]['wn6'])+'</div>';
					sum_wn6 += MembersArray[i]['wn6'];
					sum_xwn += MembersArray[i]['xwn'];
				}
				if(j == 12){
					td.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[i]['bs'])+'</div>';
					sum_bs += MembersArray[i]['bs'];
				}				
				if(j == 13){
					td.setAttribute('id', i);
					td.setAttribute('style', 'padding-left: 5px; padding-right: 5px; cursor: pointer; color: #F25322;  text-align: center;');
					td.innerHTML = '+';
					if(td.addEventListener){
						td.addEventListener('click', function(e){onViewVehicles(e.target);}, false);
					}else{
						td.attachEvent('onclick', function(e){onViewVehicles(e.target);});
					}					
				}
				tr.appendChild(td);
			}
			tbody.appendChild(tr);
			
			var tr_vehicles = document.createElement('tr');
			tr_vehicles.setAttribute('class', 'vehicles');			
			var td = document.createElement('td');
			td.setAttribute('colspan', '14');
			td.setAttribute('id', 'vehicles_hide');
			td.setAttribute('class', 'vehicles'+i);
			td.setAttribute('style', 'padding: 0px; border-width: 0px; display: none;');		
			tr_vehicles.appendChild(td);			
			tbody.appendChild(tr_vehicles);
		}
		table.appendChild(tbody);		
		
		return table;
	}
	
	var companyJSON;
	function onCompanyClan(){
		companyJSON = {members: []};
		var company = document.getElementsByClassName("company");
		for(var c = 0; c < company.length; c++){
			var id = company[c].getAttribute('id');
			var value = company[c].options[company[c].selectedIndex].value;
			companyJSON.members.push({"id" : id, "company" : value,});			
		}
		setJSON(companyJSON);
	}
	
	function setJSON(data){
		var jsonString = 'json='+JSON.stringify(data)+'&type=set&clanId='+clanId;
	
		var xmlhttp;
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
		if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
			xmlhttp = new XMLHttpRequest();
		}
		xmlhttp.open("POST", "http://walkure.su/US_ClanInfo/index.php", true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-Length", jsonString.length);
		xmlhttp.send(jsonString);
		
		xdr.xget('http://walkure.su/US_ClanInfo/index.php?type=check&clanId='+clanId, checkSaveCompany);
	}
	
	function checkSaveCompany(response){
		var saveCompany = JSON.parse(response);
		if(saveCompany.toString() == companyJSON.toString()){
			wg.message_box(
				localization[lang]['box'], 
				localization[lang]['save_yes'], 
				{confirm:{text: "OK", click: function(){}}}
			);			
		}else{
			wg.message_box(
				localization[lang]['box'], 
				localization[lang]['save_no'], 
				{confirm:{text: "OK", click: function(){}}}
			);
		}
	}	
	
	function onViewVehicles(element){
		var idAt = element.getAttribute('id');
		var state = document.getElementsByClassName("vehicles"+idAt.toString())[0].getAttribute('id');
		if(state == 'vehicles_hide'){
			element.innerHTML = '-';
			document.getElementsByClassName("vehicles"+idAt.toString())[0].setAttribute('id', 'vehicles_show');
			document.getElementsByClassName("vehicles"+idAt.toString())[0].setAttribute('style', 'padding: 0px;  border-width: 0px; display: table-cell;');
			
			document.getElementsByClassName("vehicles"+idAt.toString())[0].appendChild(getVehiclesMember(idAt));		
		}else{
			element.innerHTML = '+';
			document.getElementsByClassName("vehicles"+idAt.toString())[0].setAttribute('id', 'vehicles_hide');
			document.getElementsByClassName("vehicles"+idAt.toString())[0].setAttribute('style', 'padding: 0px;  border-width: 0px; display: none;');
			
			document.getElementsByClassName("vehicles"+idAt.toString())[0].innerHTML = '';
		}		
	}

	function getVehiclesMember(i){
		var table = document.createElement('table');
		table.setAttribute('style', 'width: 100%;');
		
		var div_absolute = document.createElement('div'); div_absolute.setAttribute('class', 'vehicles_img');
		var div_championship = document.createElement('div'); div_championship.setAttribute('class', 'vehicles_img');
		var div_average = document.createElement('div'); div_average.setAttribute('class', 'vehicles_img');
		var div_junior = document.createElement('div'); div_junior.setAttribute('class', 'vehicles_img');
		
		for(var tI = 0; tI < 5; tI++){
			var type = '';
			if(tI == 0){type = 'lightTank'}
			if(tI == 1){type = 'mediumTank'}
			if(tI == 2){type = 'heavyTank'}
			if(tI == 3){type = 'AT-SPG'}
			if(tI == 4){type = 'SPG'}
			for(var num = 0; num < MembersArray[i]['vehicles'][type].length; num++){
				var tank = MembersArray[i]['vehicles'][type][num].split('<@>');
				
				var divHTML = ''+
				'<div class="member_tank_div" style="background:url(/static/3.12.0.3/common/img/nation/'+tank[1]+'.png) no-repeat;">'+
					'<a class="tooltip">'+
						'<img src="'+tank[3]+'" class="img_tank" />'+
						'<span class="classic">'+
							'<b>'+localization[lang]['tank']+': '+tank[2]+'<br />'+
							'<b>'+localization[lang]['battles']+':</b> '+tank[4]+'<br />'+
							'<b>'+localization[lang]['winrate']+':</b> '+(100/(tank[4]/tank[5])).toFixed(2)+'%<br />'+
						'</span>'+
					'</a>'+
				'</div>';
				
				if(tank[0] == 10){div_absolute.innerHTML += divHTML;}
				if(tank[0] == 8){div_championship.innerHTML += divHTML;}
				if(tank[0] == 6){div_average.innerHTML += divHTML;}
				if(tank[0] == 4){div_junior.innerHTML += divHTML;}
			}
		}
		
		for(var dI = 0; dI < 4; dI++){	
			var tr = document.createElement('tr');
			var td = document.createElement('td');
			var title_div = '';
			if(dI == 0){title_div = 'absolute'}
			if(dI == 1){title_div = 'championship'}
			if(dI == 2){title_div = 'average'}
			if(dI == 3){title_div = 'junior'}
			td.setAttribute('id', 'vehicles_hide');
			td.setAttribute('class', 'vehicles_member vehicles_member_hide vehicles_open '+title_div+i);
			td.setAttribute('style', 'padding: 0px; cursor: pointer;');
			td.innerHTML = ''+
				'<div class="title-vehicles" id="hide" open_i="'+title_div+i+'">'+
					localization[lang][title_div]+
					'<div align="right" style="float:right;"></div>'+
				'</div>';	
			if(td.addEventListener){
				td.addEventListener('click', function(e){onViewVehiclesCompany(e.target);}, false);
			}else{
				td.attachEvent('onclick', function(e){onViewVehiclesCompany(e.target);});
			}				
			if(dI == 0){td.appendChild(div_absolute);}
			if(dI == 1){td.appendChild(div_championship);}
			if(dI == 2){td.appendChild(div_average);}
			if(dI == 3){td.appendChild(div_junior);}							
			tr.appendChild(td);
			table.appendChild(tr);
		}		
		return table;
	}		

	function onViewVehiclesCompany(element){
		var attId = element.getAttribute('id');
		var open_i = element.getAttribute('open_i');
		var el = document.getElementsByClassName(open_i)[0];
		if(el === undefined){return;}
		if(attId == 'hide'){
			element.setAttribute('id', 'show');
			el.setAttribute('id', 'vehicles_show');
			el.setAttribute('class', 'vehicles_member vehicles_member_show '+open_i);
		}else{
			element.setAttribute('id', 'hide');
			el.setAttribute('id', 'vehicles_hide');
			el.setAttribute('class', 'vehicles_member vehicles_member_hide vehicles_open '+open_i);
		}
	}
	
	function onSort(name){
		var js_send_message_button = document.getElementById("js-send-message-button");
		var js_change_roles_button = document.getElementById("js-change-roles-button");
		// js_send_message_button = 1;
		// js_change_roles_button = 1;
	
		var table = document.getElementById('newtableclaninfo');
		var sort_column = document.getElementById('sort-'+name);
		
		if(sort_column.getAttribute('class') === 'desc'){
			MembersArray.sort(ASC(name));
			sort_column.setAttribute('class', 'asc');
		}else{
			MembersArray.sort(DESC(name));
			sort_column.setAttribute('class', 'desc');
		}
		
		var UserI = 0;
		for(var i = 0; i < table.rows.length; i++){
			if(i > 0){
				var row = table.rows[i];
				if(row.getAttribute('class') != 'vehicles'){
					for(j = 0; j < row.cells.length; j++){
						var cell = row.cells[j];
						if(j == 0){
							cell.innerHTML = UserI + 1;
						}
						if(j == 1){
							cell.innerHTML = '<b><a href="/community/accounts/'+MembersArray[UserI]['id']+'/">'+MembersArray[UserI]['name']+'</a></b>';
						}
						if(j == 2){
							cell.innerHTML = getRole(MembersArray[UserI]['role']);
						}
						if(j == 3){
							var viewCompany = MembersArray[UserI]['company'];
							var selectedCompany = ['', '', '', '', '', ''];
							switch(MembersArray[UserI]['company']){
								case '99':
									viewCompany = localization[lang]['stock'];
									selectedCompany[0] = 'selected';
								break
								case '1':
									viewCompany = '1 '+localization[lang]['rota'];
									selectedCompany[1] = 'selected';
								break
								case '2':
									viewCompany = '2 '+localization[lang]['rota'];
									selectedCompany[2] = 'selected';
								break
								case '3':
									viewCompany = '3 '+localization[lang]['rota'];
									selectedCompany[3] = 'selected';
								break;
								case '4':
									viewCompany = '4 '+localization[lang]['rota'];
									selectedCompany[4] = 'selected';
								break
								case '5':
									viewCompany = '5 '+localization[lang]['rota'];
									selectedCompany[5] = 'selected';
								break;
								default:
									viewCompany = localization[lang]['stock'];
									selectedCompany[0] = 'selected';
								break
							}
							if(js_send_message_button != null && js_change_roles_button !=null){
								cell.innerHTML = ''+
								'<div style="float:right;">'+
									'<select id="'+MembersArray[UserI]['id']+'" class="company">'+
										'<option value="99" '+selectedCompany[0]+'>'+localization[lang]['stock']+'</option>'+
										'<option value="1" '+selectedCompany[1]+'>1 '+localization[lang]['rota']+'</option>'+
										'<option value="2" '+selectedCompany[2]+'>2 '+localization[lang]['rota']+'</option>'+
										'<option value="3" '+selectedCompany[3]+'>3 '+localization[lang]['rota']+'</option>'+
										'<option value="4" '+selectedCompany[4]+'>4 '+localization[lang]['rota']+'</option>'+
										'<option value="5" '+selectedCompany[5]+'>5 '+localization[lang]['rota']+'</option>'+
									'</select>'+
								'</div>';
							}else if(js_send_message_button != null){
								cell.innerHTML = '<div style="float:right;">'+viewCompany+'</div>';
							}
						}
						if(j == 4){
							cell.innerHTML = '<div style="float:right;">'+MembersArray[UserI]['day']+'</div>';
						}
						if(j == 5){
							cell.innerHTML = '<div style="float:right;">'+MembersArray[UserI]['battles']+'</div>';
						}
						if(j == 6){
							cell.setAttribute('style', 'color: '+getAvgColor(MembersArray[UserI]['winrate'])+';');
							cell.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[UserI]['winrate'])+'%</div>';
						}
						if(j == 7){
							cell.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[UserI]['survived_percents'])+'%</div>';
						}					
						if(j == 8){
							cell.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[UserI]['damage'])+'</div>';
						}						
						if(j == 9){
							cell.innerHTML = '<div style="float:right;">'+MembersArray[UserI]['hits_percents']+'%</div>';
						}
						if(j == 10){
							cell.setAttribute('style', 'color: '+getXVMColor(MembersArray[UserI]['xeff'])+';');
							cell.innerHTML = '<div style="float:left;"><b>'+Math.ceil(MembersArray[UserI]['xeff'])+'</b></div><div style="float:right;">'+Math.ceil(MembersArray[UserI]['kpd'])+'</div>';
						}
						if(j == 11){
							cell.setAttribute('style', 'color: '+getXVMColor(MembersArray[UserI]['xwn'])+';');
							cell.innerHTML = '<div style="float:left;"><b>'+Math.ceil(MembersArray[UserI]['xwn'])+'</b></div><div style="float:right;">'+Math.ceil(MembersArray[UserI]['wn6'])+'</div>';
						}
						if(j == 12){
							cell.innerHTML = '<div style="float:right;">'+Math.ceil(MembersArray[UserI]['bs'])+'</div>';
						}						
						if(j == 13){
							cell.setAttribute('id', UserI);
							cell.setAttribute('style', 'padding-left: 5px; padding-right: 5px; cursor: pointer; color: #F25322; text-align: center;');
							cell.innerHTML = '+';
						}
					}
				}else{
					var cell = row.cells[0];
					cell.setAttribute('id', 'vehicles_hide');
					cell.setAttribute('class', 'vehicles'+UserI);
					cell.setAttribute('style', 'padding: 0px;  border-width: 0px; display: none;');
					cell.innerHTML = '';
					UserI++;
				}				
			}		
		}
	}		

	function getHeadTable(attId, name, style, sort_class, tr_head){	
		var th = document.createElement('th');
		if(attId){
			th.setAttribute('id', 'sort-'+name);
			th.addEventListener("click", function(){onSort(name);}, false);
			th.innerHTML += '<span class="b-sort-box"><i></i>'+localization[lang][name]+'</span>';
		}else{
			th.innerHTML += '<span>'+localization[lang][name]+'</span>';
		}
		if(style){
			th.setAttribute('style', style);
		}
		if(sort_class){
			th.setAttribute('class', sort_class);
		}
		tr_head.appendChild(th);
	}
	
	function HideShowBlock(){
		if(visible == -1){
			visible = 1;
			
			document.getElementById("checkrunclaninfo").setAttribute('class', 'b-checkbox checked');
			
			$(".showclaninfo").hide();
			$(".t-table-sort").hide();
			$(".b-clan-buttons").hide();
			
			$("#battles_head_block").hide();
			$(".battles_head").hide();
			$("#provinces_head_block").hide();
			$(".provinces_head").hide();			
		}else if(visible == 1){
			visible = 0;
			
			document.getElementById("checkrunclaninfo").setAttribute('class', 'b-checkbox');
			
			$(".t-table-sort").show();
			$(".b-clan-buttons").show();
			
			$("#battles_head_block").show();
			$(".battles_head").show();
			$("#provinces_head_block").show();
			$(".provinces_head").show();

			$("#caption").hide();
			$("#newtableclaninfo").hide();	
			$("#structure_head_block").hide();
			$(".structure_head").hide();
			$("#rating_head_block").hide();
			$(".rating_head").hide();
			$("#vehicle_head_block").hide();
			$(".vehicle_head").hide();
			$("#cf_head_block").hide();
			$(".cf_head").hide();
		}else if(visible == 0){
			visible = 1;
			
			document.getElementById("checkrunclaninfo").setAttribute('class', 'b-checkbox checked');
			
			$(".t-table-sort").hide();
			$(".b-clan-buttons").hide();
			
			$("#battles_head_block").hide();
			$(".battles_head").hide();
			$("#provinces_head_block").hide();
			$(".provinces_head").hide();	

			$("#caption").show();
			$("#newtableclaninfo").show();	
			$("#structure_head_block").show();
			$(".structure_head").show();
			$("#rating_head_block").show();
			$(".rating_head").show();
			$("#vehicle_head_block").show();
			$(".vehicle_head").show();
			$("#cf_head_block").show();
			$(".cf_head").show();			
		}
	}
	addScript('var visible = -1; '+HideShowBlock.toString());	
	
	function onViewScript(){
		var clainfoscript = document.getElementsByClassName("clainfoscript")[0];
		var style = clainfoscript.getAttribute('class');
		if(style == 'clainfoscript show'){
			$(".script_block").attr('style', 'display: none;');	
			clainfoscript.setAttribute('class', 'clainfoscript hide');
		}else{
			$(".script_block").attr('style', 'display: block;');	
			clainfoscript.setAttribute('class', 'clainfoscript show');
		}
	}
	addScript(onViewScript);	
	
	function getCookie(c_name){
		var c_value = document.cookie;
		var c_start = c_value.indexOf(" " + c_name + "=");
		if(c_start == -1){
			c_start = c_value.indexOf(c_name + "=");
		}
		if(c_start == -1){
			c_value = null;
		}else{
			c_start = c_value.indexOf("=", c_start) + 1;
			var c_end = c_value.indexOf(";", c_start);
			if(c_end == -1){
				c_end = c_value.length;
			}
			c_value = unescape(c_value.substring(c_start,c_end));
		}
		return c_value;
	}
	addScript(getCookie);

	function setCookie(c_name, value){
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + 365);
		var c_value=escape(value) + ((365==null) ? "" : "; expires="+exdate.toUTCString()+"; domain=" +window.location.hostname+"; path=/");
		document.cookie=c_name + "=" + c_value;
	}
	addScript(setCookie);

	function ASC(a){
		return function (b, c){
			if(a == 0){
				return b[a].toLowerCase() < c[a].toLowerCase() ? -1 : b[a].toLowerCase() > c[a].toLowerCase() ? 1 : 0;
			}else{
				return b[a] < c[a] ? -1 : b[a] > c[a] ? 1 : 0;
			}
		}
	};
	
	function DESC(a){
		return function (b, c){
			if(a == 0){
				return b[a].toLowerCase() > c[a].toLowerCase() ? -1 : b[a].toLowerCase() < c[a].toLowerCase() ? 1 : 0;
			}else{
				return b[a] > c[a] ? -1 : b[a] < c[a] ? 1 : 0;
			}
		}
	};	

	function find(array, value){
		for(var i=0; i < array.length; i++){
			if (array[i] == value) return i;
		}
		return -1;
	}	
	
	function getNumerRole(role){
		var num_role = 8;
		if(role == 'leader'){num_role = 1;}
		if(role == 'vice_leader'){num_role = 2;}
		if(role == 'commander'){num_role = 3;}
		if(role == 'recruiter'){num_role = 4;}
		if(role == 'diplomat'){num_role = 5;}
		if(role == 'treasurer'){num_role = 6;}
		if(role == 'private'){num_role = 7;}
		if(role == 'recruit'){num_role = 8;}
		return num_role;
	}	

	function getRole(numer){
		var locale_role = '';
		if(numer == 0){locale_role = '-';}
		if(numer == 1){locale_role = localization[lang]['leader'];}
		if(numer == 2){locale_role = localization[lang]['vice_leader'];}
		if(numer == 3){locale_role = localization[lang]['commander'];}
		if(numer == 4){locale_role = localization[lang]['recruiter'];}
		if(numer == 5){locale_role = localization[lang]['diplomat'];}
		if(numer == 6){locale_role = localization[lang]['treasurer'];}
		if(numer == 7){locale_role = localization[lang]['private'];}
		if(numer == 8){locale_role = localization[lang]['recruit'];}
		return locale_role;
	}
	
	function getAvgColor(avg){
		if (avg <= 46.5) return "#FE0E00";
		if (avg <= 48.5) return "#FE7903";
		if (avg <= 51.5) return "#F8F400";
		if (avg <= 56.5) return "#60FF00";
		if (avg <= 63.5) return "#02C9B3";
		if (avg <= 101)	return "#D042F3";
	}
	
	function getKpdColor(kpd){
		if (kpd <= 630) return "#FE0E00";
		if (kpd <= 860) return "#FE7903";
		if (kpd <= 1140) return "#F8F400";
		if (kpd <= 1460) return "#60FF00";
		if (kpd <= 1735) return "#02C9B3";
		if (kpd <= 9999) return "#D042F3";	
	}
	
	function getWn6Color(wn6){
		if (wn6 <= 425) return "#FE0E00";
		if (wn6 <= 795) return "#FE7903";
		if (wn6 <= 1175) return "#F8F400";
		if (wn6 <= 1570) return "#60FF00";
		if (wn6 <= 1885) return "#02C9B3";
		if (wn6 <= 9999) return "#D042F3";	
	}
	
	function getXVMColor(xvm){
		if (xvm <= 16.5) return "#FE0E00";
		if (xvm <= 33.5) return "#FE7903";
		if (xvm <= 52.5) return "#F8F400";
		if (xvm <= 75.5) return "#60FF00";
		if (xvm <= 92.5) return "#02C9B3";
		if (xvm <= 101) return "#D042F3";
	}

	function getLocalization(){
		var localization = []; localization['ru'] = []; localization['en'] = []; localization['ko'] = []; localization['th'] = []; localization['zh-tw'] = [];
		
		localization['ru']['clainfoscript'] = 'Скрипт';		
		localization['en']['clainfoscript'] = 'Script';		
		localization['ko']['clainfoscript'] = '스크립트';
		localization['zh-tw']['clainfoscript'] = '脚本';
		localization['th']['clainfoscript'] = 'ต้นฉบับ';
		localization['ru']['developer'] = 'Разработчик UserScript ClanInfo: ';
		localization['en']['developer'] = 'Developer UserScript ClanInfo: ';		
		localization['ko']['developer'] = '개발자 UserScript ClanInfo: ';
		localization['zh-tw']['developer'] = '用户脚本开发ClanInfo：';
		localization['th']['developer'] = 'ClanInfo พัฒนา UserScript: ';
		localization['ru']['alliance'] = ' член альянса ';
		localization['en']['alliance'] = ' alliance member ';	
		localization['ko']['alliance'] = ' 제휴 회원 ';
		localization['zh-tw']['alliance'] = '联盟成员';
		localization['th']['alliance'] = '  สมาชิกพันธมิตร  ';
		localization['ru']['topic'] = 'Тема на форуме:';
		localization['en']['topic'] = 'Forum topic:';
		localization['ko']['topic'] = '포럼 주제:';
		localization['zh-tw']['topic'] = '论坛主题：';
		localization['th']['topic'] = 'หัวข้อ Forum:';
		localization['ru']['information'] = 'Показать дополнительную информацию по клану';
		localization['en']['information'] = 'See additional information on the clan';		
		localization['ko']['information'] = '일족에 대한 추가 정보를 참조하십시오';	
		localization['zh-tw']['information'] = '见氏族的其他信息';
		localization['th']['information'] = 'ดูข้อมูลเพิ่มเติมเกี่ยวกับตระกูล';	
		localization['ru']['save_clan'] = 'Сохранить распределение рот';
		localization['en']['save_clan'] = 'Save the distribution of mouth';
		localization['ko']['save_clan'] = '입의 분포를 저장';
		localization['zh-tw']['save_clan'] = '保存的分布口';
		localization['th']['save_clan'] = 'บันทึกการกระจายตัวของปาก';
		localization['ru']['save_yes'] = 'Распределение на роты успешно сохранено';	
		localization['en']['save_yes'] = 'Distribution on the company successfully saved';		
		localization['ko']['save_yes'] = '성공적으로 저장 회사에 배포';		
		localization['zh-tw']['save_yes'] = '分布在该公司成功保存';		
		localization['th']['save_yes'] = 'การจัดจำหน่ายของ บริษัท ประสบความสำเร็จในการบันทึก';		
		localization['ru']['save_no'] = 'Не удалось сохранить распределение на роты';
		localization['en']['save_no'] = 'Unable to save on distribution companies';
		localization['ko']['save_no'] = '유통 회사에 저장할 수 없습니다';
		localization['zh-tw']['save_no'] = '流通企业无法保存';
		localization['th']['save_no'] = 'ไม่สามารถบันทึกเมื่อ บริษัท จำหน่าย';
		
		localization['ru']['newversion'] = 'Вышла новая версия скрипта';
		localization['en']['newversion'] = 'The new version of the script';
		localization['ko']['newversion'] = '스크립트의 새 버전';
		localization['zh-tw']['newversion'] = '新版本的脚本';
		localization['th']['newversion'] = 'รุ่นใหม่ของสคริปต์';
		localization['ru']['newupdate'] = 'Пожалуйста, обновите скрипт';
		localization['en']['newupdate'] = 'Please update script';
		localization['ko']['newupdate'] = '스크립트를 업데이트하십시오';
		localization['zh-tw']['newupdate'] = '请更新脚本';
		localization['th']['newupdate'] = 'โปรดอัปเดตสคริปต์';
		localization['ru']['box'] = 'Оповещение';
		localization['en']['box'] = 'Notification';
		localization['ko']['box'] = '공고';
		localization['zh-tw']['box'] = '通知';
		localization['th']['box'] = 'การประกาศ';
		
		localization['ru']['errorClan'] = 'Не удалось получить состав клана, api.'+document.location.host+' не отвечает!\nОбновите страницу и/или попробуйте позднее.';
		localization['en']['errorClan'] = 'Unable to get the composition of clan, api.'+document.location.host+' not responding!\nRefresh the page, and / or try again later.'
		localization['ko']['errorClan'] = '일족의 구성을 얻을 수없는, api.'+document.location.host+' 가 응답하지 않습니다!\n페이지 및 / 또는 나중에 다시 시도를 새로 고칩니다.';
		localization['zh-tw']['errorClan'] = '无法获得氏族组成的，api.'+document.location.host+' 没有响应！\n 刷新页面，和/或稍后再试。';
		localization['th']['errorClan'] = 'ไม่สามารถรับองค์ประกอบของตระกูล api.'+document.location.host+' ไม่ตอบสนอง!\nรีเฟรชหน้าเว็บและ / หรือลองอีกครั้งในภายหลัง';
		localization['ru']['error_message'] = 'Ошибка получения данных игроков: ';
		localization['en']['error_message'] = 'Failure to get these players: ';
		localization['ko']['error_message'] = '이 선수를 얻기 위해 실패: ';
		localization['zh-tw']['error_message'] = '如果得到这些球员:';
		localization['th']['error_message'] = 'ล้มเหลวที่จะได้รับผู้เล่นเหล่านี้ :';
		localization['ru']['wait'] = 'Пожалуйста, подождите ...';
		localization['en']['wait'] = 'Please wait ...';
		localization['ko']['wait'] = '잠시 기다려주세요 ...';
		localization['zh-tw']['wait'] = '请稍候...';		
		localization['th']['wait'] = 'โปรดรอสักครู่ ...';		

		localization['ru']['clan'] = 'Клан на';
		localization['en']['clan'] = 'Clan on';
		localization['ko']['clan'] = '에 일족';
		localization['zh-tw']['clan'] = '宗族对';
		localization['th']['clan'] = 'Clan บน';
		
		localization['ru']['battles_head_block'] = 'Блок "Список боёв"';
		localization['en']['battles_head_block'] = 'Block "List of Fights"';
		localization['ko']['battles_head_block'] = '블록 "싸움의 목록"';
		localization['zh-tw']['battles_head_block'] = '座“名单打架”';
		localization['th']['battles_head_block'] = '"Block รายการของการต่อสู้"';
		localization['ru']['provinces_head_block'] = 'Блок "Cписок владений"';
		localization['en']['provinces_head_block'] = 'Block "List of possessions"';
		localization['ko']['provinces_head_block'] = '블록 "재산 목록"';
		localization['zh-tw']['provinces_head_block'] = '阻止“列表域”';
		localization['th']['provinces_head_block'] = 'Block "รายชื่อดินแดน"';
		localization['ru']['cf_head_block'] = 'Блок "Cредних показателей"';
		localization['en']['cf_head_block'] = 'Block "Medium indicators"';
		localization['ko']['cf_head_block'] = '"중간 지표를"차단';
		localization['zh-tw']['cf_head_block'] = '座“平均指数”';
		localization['th']['cf_head_block'] = 'บล็อก "ชี้กลาง"';
		localization['ru']['cf_head'] = 'Средние показатели по клану';
		localization['en']['cf_head'] = 'The average for the clan';
		localization['ko']['cf_head'] = '일족의 평균';
		localization['zh-tw']['cf_head'] = '平均氏族';
		localization['th']['cf_head'] = 'ค่าเฉลี่ยสำหรับตระกูล';
		localization['ru']['vehicle_head'] = 'Количество техники в клане';
		localization['en']['vehicle_head'] = 'The number of vehicles in a clan';
		localization['ko']['vehicle_head'] = '일족의 차량의 수';
		localization['zh-tw']['vehicle_head'] = '车辆的数量在氏族';
		localization['th']['vehicle_head'] = 'จำนวนของยานพาหนะในตระกูล';
		localization['ru']['vehicle_head_block'] = 'Блок "Количество техники"';
		localization['en']['vehicle_head_block'] = 'Block "Number of vehicles"';
		localization['ko']['vehicle_head_block'] = '"차량 번호"차단';
		localization['zh-tw']['vehicle_head_block'] = '座“的车辆数”';		
		localization['th']['vehicle_head_block'] = 'บล็อก "จำนวนยานพาหนะ"';			
		localization['ru']['rating_head'] = 'Лучшие рейтинги клана';
		localization['en']['rating_head'] = 'Top Ratings Clan';
		localization['ko']['rating_head'] = '최고 등급 클랜';
		localization['zh-tw']['rating_head'] = '最高评价氏族';
		localization['th']['rating_head'] = 'Clan คะแนนสูงสุด';
		localization['ru']['rating_head_block'] = 'Блок "Лучшие рейтинги"';
		localization['en']['rating_head_block'] = 'Block "Top Ratings"';
		localization['ko']['rating_head_block'] = '"최고 등급"을 차단';	
		localization['zh-tw']['rating_head_block'] = '座“最高评价”';
		localization['th']['rating_head_block'] = 'บล็อก "คะแนนสูงสุด"';			
		
		localization['ru']['type'] = 'Тип';
		localization['en']['type'] = 'Type';
		localization['ko']['type'] = '유형';
		localization['zh-tw']['type'] = '类型';
		localization['th']['type'] = 'ชนิด';
		localization['ru']['time'] = 'Время';
		localization['en']['time'] = 'Time';
		localization['ko']['time'] = '시간';
		localization['zh-tw']['time'] = '时间';
		localization['th']['time'] = 'เวลา';
		localization['ru']['provinces'] = 'Провинции';
		localization['en']['provinces'] = 'Provinces';
		localization['ko']['provinces'] = '지방';
		localization['zh-tw']['provinces'] = '省';
		localization['th']['provinces'] = 'จังหวัด';
		localization['ru']['arenas'] = 'Игровая карта';
		localization['en']['arenas'] = 'Arenas';
		localization['ko']['arenas'] = '경기장';
		localization['zh-tw']['arenas'] = '纸牌游戏';
		localization['th']['arenas'] = 'ไพ่เกม';
		localization['ru']['battle_no'] = 'У клана нет назначенных боёв.';
		localization['en']['battle_no'] = 'The clan has no scheduled battles.';
		localization['ko']['battle_no'] = '해당 클랜은 예정된 전투가 없습니다.';
		localization['zh-tw']['battle_no'] = '氏族没有指定打架。';
		localization['th']['battle_no'] = 'ตระกูลที่ได้รับมอบหมายไม่มีการต่อสู้';
		
		localization['ru']['title_name'] = 'Название';
		localization['en']['title_name'] = 'Name';
		localization['ko']['title_name'] = '이름';
		localization['zh-tw']['title_name'] = '名';
		localization['th']['title_name'] = 'ชื่อ';
		localization['ru']['prime_time'] = 'Прайм-тайм';
		localization['en']['prime_time'] = 'Prime Time';
		localization['ko']['prime_time'] = '작전 개시 시간';
		localization['zh-tw']['prime_time'] = '黄金时间';
		localization['th']['prime_time'] = 'เวลานายกรัฐมนตรี';
		localization['ru']['revenue'] = 'Доход';
		localization['en']['revenue'] = 'Income';
		localization['ko']['revenue'] = '수입';
		localization['zh-tw']['revenue'] = '收入';
		localization['th']['revenue'] = 'เงินได้';
		localization['ru']['occupancy_time'] = 'Время владения';
		localization['en']['occupancy_time'] = 'Time Owned';
		localization['ko']['occupancy_time'] = '소유 시간';
		localization['zh-tw']['occupancy_time'] = '藏时间';
		localization['th']['occupancy_time'] = 'ช่วงเวลาของการมีไว้ในครอบครอง';
		localization['ru']['occupancy_day'] = '(дн.)';
		localization['en']['occupancy_day'] = '(days.)';
		localization['ko']['occupancy_day'] = '(일수)';
		localization['zh-tw']['occupancy_day'] = '（天数）';
		localization['th']['occupancy_day'] = '(ในวัน)';
		localization['ru']['provinces_count'] = 'Всего провинций:';
		localization['en']['provinces_count'] = 'Provinces total:';
		localization['ko']['provinces_count'] = '총 지역 수:';
		localization['zh-tw']['provinces_count'] = '总省份：';
		localization['th']['provinces_count'] = 'จังหวัดทั้งหมด:';
		localization['ru']['total_revenue'] = 'Общий доход:';
		localization['en']['total_revenue'] = 'Total income:';
		localization['ko']['total_revenue'] = '총 수입:';
		localization['zh-tw']['total_revenue'] = '总收入：';
		localization['th']['total_revenue'] = 'รายได้รวม:';
		localization['ru']['provinces_no'] = 'У клана нет владений на глобальной карте.';
		localization['en']['provinces_no'] = 'The clan owns no provinces on the Global Map.';
		localization['ko']['provinces_no'] = '해당 클랜은 세계 지도에 점령한 지역이 없습니다.';	
		localization['zh-tw']['provinces_no'] = '氏族有没有在世界地图上的财产。';
		localization['th']['provinces_no'] = 'ตระกูลมีทรัพย์สินที่ไม่มีบนแผนที่โลก';		

		localization['ru']['numer'] = '№';
		localization['en']['numer'] = '№';
		localization['ko']['numer'] = '№';
		localization['zh-tw']['numer'] = '№';
		localization['th']['numer'] = '№';
		localization['ru']['space'] = ' ';
		localization['en']['space'] = ' ';
		localization['ko']['space'] = ' ';	
		localization['zh-tw']['space'] = '';
		localization['th']['space'] = ' ';		
		localization['ru']['name'] = 'Имя';
		localization['en']['name'] = 'User Name';		
		localization['ko']['name'] = '사용자 이름';
		localization['zh-tw']['name'] = '名';
		localization['th']['name'] = 'ชื่อ';		
		localization['ru']['role'] = 'Должность';		
		localization['en']['role'] = 'Position';					
		localization['ko']['role'] = '위치';
		localization['zh-tw']['role'] = '位置';		
		localization['th']['role'] = 'ตำแหน่ง';	
		localization['ru']['company'] = 'Рота';
		localization['en']['company'] = 'Company';	
		localization['ko']['company'] = '회사';		
		localization['zh-tw']['company'] = '公司';		
		localization['th']['company'] = 'บริษัท';		
		localization['ru']['day'] = 'Дней';
		localization['en']['day'] = 'Days';		
		localization['ko']['day'] = '일';
		localization['zh-tw']['day'] = '天';		
		localization['th']['day'] = 'วัน';		
		localization['ru']['battles'] = 'Боёв';
		localization['en']['battles'] = 'Battles';		
		localization['ko']['battles'] = '전투';	
		localization['zh-tw']['battles'] = '战斗';
		localization['th']['battles'] = 'การต่อสู้';		
		localization['ru']['damage'] = 'Ср.урон';
		localization['en']['damage'] = 'Cf.damage';		
		localization['ko']['damage'] = '참조. 손해';
		localization['zh-tw']['damage'] = '比照损坏';
		localization['th']['damage'] = 'ความเสียหาย';		
		localization['ru']['winrate'] = 'Побед';
		localization['en']['winrate'] = 'Wins';	
		localization['ko']['winrate'] = '승';	
		localization['zh-tw']['winrate'] = '胜';
		localization['th']['winrate'] = 'คว้ารางวัลชนะเลิศ';	
		localization['ru']['hits_percents'] = 'Меткость';
		localization['en']['hits_percents'] = 'Accuracy';		
		localization['ko']['hits_percents'] = '적중률';	
		localization['zh-tw']['hits_percents'] = '准确性';
		localization['th']['hits_percents'] = 'ความถูกต้อง';		
		localization['ru']['survived_percents'] = 'Выжил';
		localization['en']['survived_percents'] = 'Survived';		
		localization['ko']['survived_percents'] = '살아';
		localization['zh-tw']['survived_percents'] = '大难不死';
		localization['th']['survived_percents'] = 'รอดชีวิตมาได้';			
		localization['ru']['survivalsum'] = 'Выживание';
		localization['en']['survivalsum'] = 'Survival';
		localization['ko']['survivalsum'] = '살아 남기';	
		localization['zh-tw']['survivalsum'] = '生存';
		localization['th']['survivalsum'] = 'การอยู่รอด';	
		localization['ru']['kpd'] = 'Р.Э.';
		localization['en']['kpd'] = 'Rating';		
		localization['ko']['kpd'] = '평가';	
		localization['zh-tw']['kpd'] = '等级';
		localization['th']['kpd'] = 'การจัดอันดับ';		
		localization['ru']['wn6'] = 'WN6';
		localization['en']['wn6'] = 'WN6';
		localization['ko']['wn6'] = 'WN6';
		localization['zh-tw']['wn6'] = 'WN6';
		localization['th']['wn6'] = 'WN6';
		localization['ru']['bs'] = 'Б.С.';
		localization['en']['bs'] = 'B.S.';
		localization['ko']['bs'] = 'B.S.';
		localization['zh-tw']['bs'] = 'B.S.';		
		localization['th']['bs'] = 'B.S.';	
		localization['ru']['stock'] = 'Запас';
		localization['en']['stock'] = 'Stock';
		localization['ko']['stock'] = '스톡';
		localization['zh-tw']['stock'] = '股票';
		localization['th']['stock'] = 'คลังสินค้า';
		localization['ru']['rota'] = 'Рота';
		localization['en']['rota'] = 'Company';
		localization['ko']['rota'] = '회사';
		localization['zh-tw']['rota'] = '公司';
		localization['th']['rota'] = 'บริษัท';
		
		localization['ru']['leader'] = 'Командир';
		localization['en']['leader'] = 'Commander';
		localization['ko']['leader'] = '사령관';
		localization['zh-tw']['leader'] = '指挥官';
		localization['th']['leader'] = 'ผู้บังคับบัญชา';
		localization['ru']['vice_leader'] = 'Зам. командир';
		localization['en']['vice_leader'] = 'Deputy Commander';
		localization['ko']['vice_leader'] = '부사령관';
		localization['zh-tw']['vice_leader'] = '副司令员';
		localization['th']['vice_leader'] = 'รอง ผู้บังคับบัญชา';
		localization['ru']['commander'] = 'Ротный командир';
		localization['en']['commander'] = 'Field Commander';
		localization['ko']['commander'] = '부사령관';
		localization['zh-tw']['commander'] = '副。指挥官';
		localization['th']['commander'] = 'รองผู้บัญชาการ';
		localization['ru']['recruiter'] = 'Вербовщик';
		localization['en']['recruiter'] = 'Recruiter';
		localization['ko']['recruiter'] = '모집';
		localization['zh-tw']['recruiter'] = '招聘人员';
		localization['th']['recruiter'] = 'ผู้รับคนใหม่';
		localization['ru']['diplomat'] = 'Дипломат';
		localization['en']['diplomat'] = 'Diplomat';
		localization['ko']['diplomat'] = '외교관';
		localization['zh-tw']['diplomat'] = '外交官';
		localization['th']['diplomat'] = 'นักการทูต';
		localization['ru']['treasurer'] = 'Казначей';
		localization['en']['treasurer'] = 'Treasurer';
		localization['ko']['treasurer'] = '회계 원';
		localization['zh-tw']['treasurer'] = '出纳员';
		localization['th']['treasurer'] = 'เหรัญญิก';
		localization['ru']['private'] = 'Солдат';
		localization['en']['private'] = 'Soldier';
		localization['ko']['private'] = '군인';
		localization['zh-tw']['private'] = '士兵';
		localization['th']['private'] = 'ทหาร';
		localization['ru']['recruit'] = 'Новобранец';
		localization['en']['recruit'] = 'Recruit';
		localization['ko']['recruit'] = '채용';	
		localization['zh-tw']['recruit'] = '新秀';
		localization['th']['recruit'] = 'มือใหม่';		
		
		localization['ru']['absolute'] = 'Техника для абсолютной роты';
		localization['en']['absolute'] = 'Technique for absolute company';
		localization['ko']['absolute'] = '절대 회사에 대한 기술';
		localization['zh-tw']['absolute'] = '绝对公司技术';
		localization['th']['absolute'] = 'เทคนิคสำหรับ บริษัท แน่นอน';
		localization['ru']['championship'] = 'Техника для чемпионской роты';
		localization['en']['championship'] = 'Technique for the champion company';
		localization['ko']['championship'] = '챔피언 기업에 대한 기술';
		localization['zh-tw']['championship'] = '冠军科技公司';
		localization['th']['championship'] = 'บริษัท เทคแชมป์';
		localization['ru']['average'] = 'Техника для средней роты';
		localization['en']['average'] = 'Technique for the average company';
		localization['ko']['average'] = '일반 회사의 기술';
		localization['zh-tw']['average'] = '公司平均技术';
		localization['th']['average'] = 'เทคนิคให้กับ บริษัท เฉลี่ย';
		localization['ru']['junior'] = 'Техника для юниорской роты';
		localization['en']['junior'] = 'Technique for junior company';
		localization['ko']['junior'] = '중학교 회사의 기술';
		localization['zh-tw']['junior'] = '初级公司技术';
		localization['th']['junior'] = 'เทคนิคสำหรับ บริษัท จูเนียร์';

		localization['ru']['tank'] = 'Танк';
		localization['en']['tank'] = 'Tank';
		localization['ko']['tank'] = '탱크';
		localization['zh-tw']['tank'] = '坦克';
		localization['th']['tank'] = 'ถัง';
		localization['ru']['yes_tank'] = 'Есть';
		localization['en']['yes_tank'] = 'There\'s';
		localization['ko']['yes_tank'] = '거기에';
		localization['zh-tw']['yes_tank'] = '有';
		localization['th']['yes_tank'] = 'นอกจากนี้';
		localization['ru']['no_tank'] = 'Нет';
		localization['en']['no_tank'] = 'Not';
		localization['ko']['no_tank'] = '아니';	
		localization['zh-tw']['no_tank'] = '没有';
		localization['th']['no_tank'] = 'ไม่';	

		localization['ru']['rating'] = 'Рейтинг';
		localization['en']['rating'] = 'Rating';
		localization['ko']['rating'] = '평가';
		localization['zh-tw']['rating'] = '等级';
		localization['th']['rating'] = 'การจัดอันดับ';
		localization['ru']['name'] = 'Имя';
		localization['en']['name'] = 'Name';
		localization['ko']['name'] = '이름';
		localization['zh-tw']['name'] = '名';
		localization['th']['name'] = 'ชื่อ';
		localization['ru']['value'] = 'Значение';
		localization['en']['value'] = 'Value';
		localization['ko']['value'] = '값';
		localization['zh-tw']['value'] = '值';
		localization['th']['value'] = 'มูลค่า';
		localization['ru']['place'] = 'Место';
		localization['en']['place'] = 'Place';
		localization['ko']['place'] = '장소';
		localization['zh-tw']['place'] = '地方';
		localization['th']['place'] = 'สถานที่';
		
		localization['ru']['lightTank'] = 'Легкие танки';
		localization['en']['lightTank'] = 'Light Tanks';
		localization['ko']['lightTank'] = '경전차';
		localization['zh-tw']['lightTank'] = '轻型坦克';
		localization['th']['lightTank'] = 'ไฟถัง';
		localization['ru']['mediumTank'] = 'Средние танки';
		localization['en']['mediumTank'] = 'Medium tanks';
		localization['ko']['mediumTank'] = '중형전차';
		localization['zh-tw']['mediumTank'] = '中型坦克';
		localization['th']['mediumTank'] = 'รถถังกลาง';
		localization['ru']['heavyTank'] = 'Тяжёлые танки';
		localization['en']['heavyTank'] = 'Heavy tanks';
		localization['ko']['heavyTank'] = '중전차';
		localization['zh-tw']['heavyTank'] = '重型坦克';
		localization['th']['heavyTank'] = 'รถถังหนัก';
		localization['ru']['AT-SPG'] = 'ПТ-САУ';
		localization['en']['AT-SPG'] = 'AT-SPG';
		localization['ko']['AT-SPG'] = '구축전차';
		localization['zh-tw']['AT-SPG'] = '驅逐戰車';
		localization['th']['AT-SPG'] = 'ยานเกระาพิฆาตรถถัง';
		localization['ru']['SPG'] = 'САУ';
		localization['en']['SPG'] = 'SPG';
		localization['ko']['SPG'] = '자주포';
		localization['zh-tw']['SPG'] = '自走炮';
		localization['th']['SPG'] = 'ปืนใหญ่อัตตาจร';

		localization['ru']['gr'] = 'Общий рейтинг';
		localization['en']['gr'] = 'Global Rating';
		localization['ko']['gr'] = '전체 순위';
		localization['zh-tw']['gr'] = '总体评价';
		localization['th']['gr'] = 'ลำดับทั่วโลก';
		localization['ru']['wb'] = 'Процент побед';
		localization['en']['wb'] = 'Victories/Battles';
		localization['ko']['wb'] = '승률';
		localization['zh-tw']['wb'] = '占胜';
		localization['th']['wb'] = 'ชัยชนะ/การรบ';
		localization['ru']['eb'] = 'Средний опыт за бой';
		localization['en']['eb'] = 'Average Experience per Battle';
		localization['ko']['eb'] = '전투 당 평균 경험치';
		localization['zh-tw']['eb'] = '平均每战经验';
		localization['th']['eb'] = 'ค่าประสบการณ์เฉลี่ยในการรบ';
		localization['ru']['win'] = 'Победы';
		localization['en']['win'] = 'Victories';
		localization['ko']['win'] = '승리';
		localization['zh-tw']['win'] = '胜利';
		localization['th']['win'] = 'ชัยชนะ';
		localization['ru']['gpl'] = 'Проведено боёв';
		localization['en']['gpl'] = 'Battles Participated';
		localization['ko']['gpl'] = '참전';
		localization['zh-tw']['gpl'] = '玩过的游戏';
		localization['th']['gpl'] = 'การรบที่ได้เข้าร่วม';
		localization['ru']['cpt'] = 'Захват базы';
		localization['en']['cpt'] = 'Capture Points';
		localization['ko']['cpt'] = '점령 점수';
		localization['zh-tw']['cpt'] = '捕获';
		localization['th']['cpt'] = 'คะแนนการบุกยึด';
		localization['ru']['dmg'] = 'Нанесённые повреждения';
		localization['en']['dmg'] = 'Damage Caused';
		localization['ko']['dmg'] = '누적 공격력';
		localization['zh-tw']['dmg'] = '损坏';
		localization['th']['dmg'] = 'ความเสียหาย';
		localization['ru']['dpt'] = 'Защита базы';
		localization['en']['dpt'] = 'Defense Points';
		localization['ko']['dpt'] = '방어 점수';
		localization['zh-tw']['dpt'] = '保卫基地';
		localization['th']['dpt'] = 'คะแนนการป้องกัน';
		localization['ru']['frg'] = 'Уничтожено врагов';
		localization['en']['frg'] = 'Targets Destroyed';
		localization['ko']['frg'] = '격파 횟수';
		localization['zh-tw']['frg'] = '打败的敌人';
		localization['th']['frg'] = 'เป้าหมายที่ถูกทำลาย';
		localization['ru']['spt'] = 'Обнаруженные враги';
		localization['en']['spt'] = 'Targets Detected';
		localization['ko']['spt'] = '탐지 횟수';
		localization['zh-tw']['spt'] = '发现敌人';
		localization['th']['spt'] = 'พบเป้าหมาย';
		localization['ru']['exp'] = 'Суммарный опыт';
		localization['en']['exp'] = 'Experience';
		localization['ko']['exp'] = '경험치';
		localization['zh-tw']['exp'] = '总经验';		
		localization['th']['exp'] = 'ค่าประสบการณ์';		
		
		return localization;
	}

	main();	
}